git rebase -i HEAD~N
Example, remove the latest commit:
git rebase -i HEAD~2
The editor window that pops up will show this:
pick 6e8d7a9 Fixes #31. Closing using fixes #xxx.
pick b613bf0 Added sample file to remove from local and remote repository.
# Rebase 947fe36..b613bf0 onto 947fe36
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
# However, if you remove everything, the rebase will be aborted.
#
git push origin +master