You need to use git rebase --interactive:
git rebase --interactive HEAD~3
- This will bring up an editor containing something like this:
pick aaaaaaaa commit A
pick aaaaaaaa commit B
pick cccccccc commit C
- This show the last 3 commits (hence HEAD*~3*)
- remove the first line, so it it looks like this:
pick aaaaaaaa commit B
pick cccccccc commit C
- This tells git to use only commit B and C in from the history
- Save your changes
- Close editor
Difficulty
Experience with git rebase [branch name]
( For the worst case scenario )
Worst case
Case: The commit you removed was not independent of the other commits. And now git rebase wants stuff from you, you have no idea about.
Solution: Reverse the process with git rebase --abort