Skip to content

Managing pushed git mistakes

Jared edited this page May 18, 2018 · 1 revision

Revert the full commit

Creates commit to revert the selected commit(s)

git revert {commit_id}

Rewriting commit history

Delete the last commit(s)

Reset remote to the parent of selected commit:

git push origin +{commit_id}^:{branch_name}

If you have the branch checked out locally, you can also do it in two simpler steps:

  • First reset the branch to the parent of the current commit,
  • then force-push it to the remote.
git reset HEAD^ --hard

git push origin -f