Last active
January 8, 2017 06:35
-
-
Save motss/cc1cf9a95fa5447745722d551e7b5174 to your computer and use it in GitHub Desktop.
git merge squash commits
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
// http://stackoverflow.com/questions/5189560/squash-my-last-x-commits-together-using-git | |
# Reset the current branch to the commit just before the last 12: | |
git reset --hard HEAD~12 | |
# 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 | |
# git reset --hard is not the end of the world. Use `git reflog` to reset again. | |
git reflog |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment