Skip to content

Instantly share code, notes, and snippets.

@scodx
Last active August 15, 2018 17:21
Show Gist options
  • Select an option

  • Save scodx/e2e6f13ad5baa48aab75885ddfeac9fe to your computer and use it in GitHub Desktop.

Select an option

Save scodx/e2e6f13ad5baa48aab75885ddfeac9fe to your computer and use it in GitHub Desktop.

Assuming that your branch is called master both here and remotely, and that your remote is called origin you could do:

git reset --hard <commit-hash>
git push -f origin master

Use the other answers if you don't mind losing local changes. This method can still wreck your remote if you choose the wrong commit hash to go back to.

If you just want to make the remote match a commit that's already in your local branch:

git push --force <remote> <the-hash>:<the remote branch>

e.g.

git push --force origin 606fdfaa33af1844c86f4267a136d4666e576cdc:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment