# from http://stackoverflow.com/questions/5189560/squash-my-last-x-commits-together-using-git#5189600 # undo last X commits, and commit with a new message as one git reset --soft HEAD~X git commit -a -m "COMMIT MESSAGE" # undo last X commits, and commit with old messages git reset --soft HEAD~X git commit --edit -m"$(git log --format=%B --reverse HEAD..HEAD@{1})" # the kosher way of doing previous example git rebase -i (this will open an editor window, where you have to manually change all the "pick" except the first one to "squash") # undo the undo - if you change your mind git reflog > 54439b8 HEAD@{0}: reset: moving to HEAD~1 > 6fd9bfa HEAD@{1}: commit: YOUR COMMIT MESSAGE > ... git reset HEAD@{1} # or git reset 6fd9bfa