Skip to content

Instantly share code, notes, and snippets.

@raym
Created April 11, 2015 15:37
Show Gist options
  • Save raym/0ff386ee9505721e29a4 to your computer and use it in GitHub Desktop.
Save raym/0ff386ee9505721e29a4 to your computer and use it in GitHub Desktop.
ways to remove commits from git
# method 1
git reset --hard $rollback_to_hash # rollback locally
git push --force # force-push
# method 2
git reset --soft HEAD^ # remove commit locally
git push origin +master
# method 3
git reset HEAD^ # remove commit locally
git push origin +HEAD # force-push the new HEAD commit
# method 4
# if you want to still have it in your local repository and only remove it from the remote:
git push origin +HEAD^:$branchname # most likely 'master'
# more: http://www-cs-students.stanford.edu/~blynn/gitmagic/ch05.html#_8230_and_then_some
# if removing sensitive data, look here:
# http://help.github.com/remove-sensitive-data/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment