Created
November 12, 2012 10:34
-
-
Save asux/4058567 to your computer and use it in GitHub Desktop.
git commit squashing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Go back to the last commit that we want to form the initial commit (detach HEAD) | |
git checkout <sha1_for_B> | |
# reset the branch pointer to the initial commit, | |
# but leaving the index and working tree intact. | |
git reset --soft <sha1_for_A> | |
# amend the initial tree using the tree from 'B' | |
git commit --amend | |
# temporarily tag this new initial commit | |
# (or you could remember the new commit sha1 manually) | |
git tag tmp | |
# go back to the original branch (assume master for this example) | |
git checkout master | |
# Replay all the commits after B onto the new initial commit | |
git rebase --onto tmp <sha1_for_B> | |
# remove the temporary tag | |
git tag -d tmp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment