Skip to content

Instantly share code, notes, and snippets.

@muhammadghazali
Last active December 11, 2015 20:09
Show Gist options
  • Save muhammadghazali/4653775 to your computer and use it in GitHub Desktop.
Save muhammadghazali/4653775 to your computer and use it in GitHub Desktop.
How to remove commit from git remote repository. The how to is based from: http://stackoverflow.com/questions/448919/how-can-i-remove-a-commit-on-github/448929#448929

Remove n-commit on your local repository

git rebase -i HEAD~N

Delete the N line within the editor window that pops up

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.
#

Force push to github

git push origin +master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment