Rolling back to an earlier Git commit

Find the git commit you want to rollback to:


You can find all my latest posts on medium.
git log -n20
git checkout <commit hash>

Then do:

git reset --hard <commit hash>
git push origin HEAD:master --force

Note this can inconvenience some users because they can end up with conflicts since you did a a forced push.

So another approach after checking your commit, is to create a new branch and then create a PR to merge in the rollbacked code:

git checkout -b rollbacked-code
git push # then create a PR