Posted on

Remove the Commits Locally

If you only want to remove the last commit,

git reset --hard HEAD^

If you want to remove more than one, for example, 2 commits,

git reset --hard HEAD~2

Remove the Commits Remotely

Force pushing to Github by using the following command, where branchName should be replaced by the branch on which the commit resides.

git push origin +branchName --force

References

  1. https://sethrobertson.github.io/GitFixUm/fixup.html
  2. https://stackoverflow.com/questions/448919/how-can-i-remove-a-commit-on-github/448929#448929

Leave a Reply

Your email address will not be published. Required fields are marked *