Skip to content

Instantly share code, notes, and snippets.

@wlizama
Created January 12, 2024 16:49
Show Gist options
  • Save wlizama/023ce899898d47e1be6450d1614223a4 to your computer and use it in GitHub Desktop.
Save wlizama/023ce899898d47e1be6450d1614223a4 to your computer and use it in GitHub Desktop.
Revert merge commit
# ensure you are on the correct branch where the merge commit needs to be undone
git checkout main
# find the hash of the merge commit that you want to undo
git log
# Use git revert with the -m option followed by the commit hash to revert the
# merge commit. The -m option specifies the mainline parent, which is usually the branch you merged into
git revert -m 1 <merge_commit_hash>
# push the changes to the remote
git push
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment