Developer Tools

How do I reset a Git merge?

Updated 2026-08-14

Quick answer

To reset a Git merge, use the command 'git reset --merge' or 'git reset --hard HEAD' depending on whether you want to keep the changes or discard them.

This guide provides steps to reset a Git merge and outlines important considerations.

Steps

  1. 1

    Check Current Status

    Run 'git status' to see the current state of your repository and confirm that you are in a merge conflict.

  2. 2

    Reset the Merge

    Use 'git reset --merge' to keep changes or 'git reset --hard HEAD' to discard changes. Note that '--hard' will erase uncommitted changes.

  3. 3

    Verify the Reset

    Run 'git status' again to ensure that the repository is back to its previous state.

Understanding Git Merge

A Git merge combines changes from different branches. If conflicts arise or you decide not to proceed, resetting the merge can help.

Reset Options

You can choose to keep changes with 'git reset --merge' or discard them with 'git reset --hard HEAD'. Choose based on your needs.

Watch out for

  • Be cautious with 'git reset --hard' as it will erase all uncommitted changes.
  • Always ensure you are on the correct branch before performing a reset.

FAQ

What happens to my changes after a hard reset?

A hard reset will permanently discard all uncommitted changes, so ensure you have backups if needed.

Can I recover discarded changes after a hard reset?

Generally, no. Once a hard reset is performed, the changes are lost unless you have a backup or they were committed.

Is there a way to abort a merge without resetting?

Yes, you can use 'git merge --abort' to stop the merge process if you haven't committed yet.