Skip to content

Instantly share code, notes, and snippets.

@rpayanm
Created July 23, 2019 15:04
Show Gist options
  • Save rpayanm/9e04bd2f12318f6a42e6069aba09e137 to your computer and use it in GitHub Desktop.
Save rpayanm/9e04bd2f12318f6a42e6069aba09e137 to your computer and use it in GitHub Desktop.
git reset --hard <the-sha-you-want-to-return-to>

Or This will undo the last commit.

git reset --hard HEAD~1

Or This will undo the last two commits.

git reset --hard HEAD~2

Push the updated history to the remote. You need to pass the -f because you're replacing upstream history in the remote.

git push -f <remote> <branch>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment