You should just be able to change the word "pick" to "squash" in order to squash the commit marked "squash" into the preceding commit.
Git Documentation: Rewriting History
An example:
$ git log --oneline acb05b3 Some final commit. 4968dbd Fixing an error in commit df89a81. df89a81 Something committed too early. c365eab Another commit... 625889f A commit... 70f29fd The beginning.
I want to rebase onto 3 commits before the most recent:
$ git rebase -i HEAD~3
This gives the following text in a text editor:
pick df89a81 Something committed too early. pick 4968dbd Fixing an error in commit df89a81. pick acb05b3 Some final commit. # Rebase c365eab..acb05b3 onto c365eab (3 command(s))
Which I change to this:
pick df89a81 Something committed too early. squash 4968dbd Fixing an error in commit df89a81. pick acb05b3 Some final commit. # Rebase c365eab..acb05b3 onto c365eab (3 command(s))
Upon exiting, I then get another editor containing this:
# This is a combination of 2 commits. # The first commit's message is: Something committed too early. # This is the 2nd commit message: Fixing an error in commit df89a81. # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit.
Which I change to this:
# This is a combination of 2 commits. # The first commit's message is: This is the squashed commit. It and everything after it get new commit hashes. # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit.
Now if I look at my new history:
$ git log --oneline 8792fef Some final commit. df775c4 This is the squashed commit. It and everything after it get new commit hashes. c365eab Another commit... 625889f A commit... 70f29fd The beginning.