Skip to content

Instantly share code, notes, and snippets.

@barahilia
Created February 16, 2022 07:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barahilia/d2da8f627f40a8ddc947d6ab51b6711f to your computer and use it in GitHub Desktop.
Save barahilia/d2da8f627f40a8ddc947d6ab51b6711f to your computer and use it in GitHub Desktop.
# Fresh repo and some master history
git init squash
cd squash/
echo one > a
git add .
git commit -m "First commit"
echo two >> a
git commit -m "Second commit"
git commit -am "Second commit"
# Here we start working on a branch
git checkout -b branch
echo three >> a
git commit -am "Branch first"
echo four > b
git add .
git commit -m "Branch second"
# Precaution - save the current tip
git tag branch_before_sqaush
# Finally, the actual sqaush
git reset master
git add .
git commit -am "Branch squashed commit"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment