Revert Git to a specific commit

Sometimes, you might want to revert to a specific commit because the commit tree looks ugly or some other reasons. To fix it, follow these steps:

  1. Create a backup branch for safety reason.
1
$ git checkout -b backup
  1. Reset to a specific commit
1
$ git reset --hard COMMIT_ID
  1. Force push to server
1
$ git push STREAM BRANCH -f

That should be it. However, if there is any mistake, just revert from the backup branch.

Share