Skip to content

Instantly share code, notes, and snippets.

@artemgordinskiy
Last active November 22, 2022 11:56
Show Gist options
  • Save artemgordinskiy/6a69fb78e073dd0927e7aed6fb9d2ae8 to your computer and use it in GitHub Desktop.
Save artemgordinskiy/6a69fb78e073dd0927e7aed6fb9d2ae8 to your computer and use it in GitHub Desktop.
Undo multiple MRs to the main branch in git

Assuming there were one or more bad merges to the current branch and we want to go back to a cetain (merge, or otherwise) commit before them:

git checkout <good-commit-hash> -- .

This will stage all file changes without checking out any branch or putting it into a weird state.

Not that any files added since said commit will not be removed automatically, so they may need to be deleted manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment