We've changed each line's command from pick to the command we're interested in.

Now, save and close the editor; this will start the interactive rebase.

Git skips the first rebase command, pick 1fc6c95, since it doesn't need to do anything. It goes to the next command, squash fa39187. Since this operation requires your input, Git opens your text editor once again. The file it opens up looks something like this:

# This is a combination of two commits.
# The first commit's message is:
Patch A
# This is the 2nd commit message:
something to add to patch A
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# Not currently on any branch.
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: a
#

This file is Git's way of saying, "Hey, here's what I'm about to do with this squash." It lists the first commit's message ("Patch A"), and the second commit's message ("something to add to patch A"). If you're happy with these commit messages, you can save the file, and close the editor. Otherwise, you have the option of changing the commit message by simply changing the text.

Git processes the two pick commands (for pick 7b36971 and pick 6b2481b). It also processes the fixup command (fixup c619268), since it doesn't require any interaction. fixup merges the changes from c619268 into the commit before it, 6b2481b. Both changes will have the same commit message: "Patch B".

Git gets to the edit dd1475d operation, stops, and prints the following message to the terminal:

You can amend the commit now, with
git commit --amend
Once you are satisfied with your changes, run
git rebase --continue

At this point, you can edit any of the files in your project to make any additional changes. For each change you make, you'll need to perform a new commit, and you can do that by entering the git commit --amend command. When you're finished making all your changes, you can run git rebase --continue.

Git then gets to the reword 4ca2acc command. It opens up your text editor one more time, and presents the following information:

i cant' typ goods
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# Not currently on any branch.
# Changes to be committed:
# (use "git reset HEAD^1 <file>..." to unstage)
#
# modified: a
#

As before, Git is showing the commit message for you to edit. You can change the text ("i cant' typ goods"), save the file, and close the editor. Git will finish the rebase and return you to the terminal.

Pushing rebased code to GitHub

Force pushing has serious implications, especially if your repository is being accessed by multiple people. At the least, your commits in pull requests might be out of order. For more information, check out "Why are my commits in the wrong order?"