Created
September 3, 2013 20:57
-
-
Save ChristianGaertner/6429471 to your computer and use it in GitHub Desktop.
An alternative to the interactive git rebase. (I like this method better.)
This file contains 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
# Reset the current branch to the commit just before the last X: | |
# X is here the number of commits to squash together | |
git reset --hard HEAD~X | |
# HEAD@{1} is where the branch was just before the previous command. | |
# This command sets the state of the index to be as it would just | |
# after a merge from that commit: | |
git merge --squash HEAD@{1} | |
# Commit those squashed changes. The commit message will be helpfully | |
# prepopulated with the commit messages of all the squashed commits: | |
git commit | |
# or... | |
git commit -m "<...>" | |
# If you want to push to remote | |
git push --force |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment