How to easily cherrypick and remove a commit with git rebase and revert 16 October 2013

We all commit a wrong commit every once in a while and we often realize what we did much later. Long story short, to un-commit a change, there are two ways I use:

Method 1- Interactive rebase (For Private Repos):

git rebase -i SHA-OF-FIRST-COMMIT-YOU-WANT-TO-CHERRYPICK
git rebase -i master

Executing this command will open your editor defined in $EDITOR variable and show you list of commits after the commit you have specified with this command. To delete some commits, just delete their respective lines in the editor, save the file and commit it.

Method 2- Git Revert (For Public Repos)

git revert SOME-SHA-1-OF-THE-COMMIT-YOU-DONT-WANT

Running this command will create a commit that is the opposite of the commit you don’t want.

Source(s): http://stackoverflow.com/questions/1624705/git-inverse-cherry-pick