Logo
Published on

Git FAQ: How to Reset Origin/Master to a Specific Commit

Authors
  • avatar
    Name
    Mike Tsamis
    Twitter

To reset origin master to specific commit, start by checking out the master branch:

git checkout master

Next, run the following:

git reset --hard <commit_hash>

“git reset” will reset the current HEAD to a specified state. In this case, the state will be the commit hash which can be obtained by running “git log”. After resetting the HEAD, we can now force push our local changes to master.

git push --force origin master

TL;DR

git checkout master
git reset --hard <commit_hash>
git push --force origin master

Related Articles