Latest Git:

git merge --abort

This attempts to reset your working copy to whatever state it was in before the merge. That means that it should restore any uncommitted changes from before the merge, although it cannot always do so reliably. Generally you shouldn't merge with uncommitted changes anyway.

Prior to version 1.7.4:

git reset --merge

This is older syntax but does the same as the above.

Prior to version 1.6.2:

git reset --hard

which removes all uncommitted changes, including the uncommitted merge. Sometimes this behaviour is useful even in newer versions of Git that support the above commands.

Answer from Daniel Cassidy on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › git › how-to-undo-merge-in-git
How To Undo Merge in Git? - GeeksforGeeks
August 22, 2024 - Find the commit you want to recover and use git reset or git checkout to restore it. Merge Conflicts Persist After Aborting: If conflicts remain after using git merge --abort, manually clean up any lingering files in your working directory.
Discussions

How to undo a git pull that caused merge conflicts?
I accidentally ran git pull on my branch and it pulled in a bunch of changes from remote that I didn’t want — now I have merge conflicts and a messy state. Is there a clean way to undo the pull entirely and get back to the state before the pull? More on github.com
🌐 github.com
2
2
git - Restart/undo conflict resolution in a single file - Stack Overflow
In a larger git merge with several conflicting files, I incorrectly marked a file as resolved (using git add FILE after some editing) Now I'd like to undo my conflict resolution attempt and start ... More on stackoverflow.com
🌐 stackoverflow.com
Help fixing bad conflict resolution
Find and temporary tag your merge commit. (merged) Tag the current tip of your feature branch so that you can retry if you mess up. (feature-with-merge) Then the commit just before then is called either merged^1 or merged^2 depending on which direction you ran the merge. ^1 is more likely. The rebase command needs to rewind all commits after the merge and reapply them just before. That's rebase merged --onto merged^1 Which means "rewind to the common ancestor with merged then go to its first parent then replay the rewound changes. Rewinding means that the tip of branch pointer feature moves backwards and abandons commits. But those commits (merge then develop) will still be accessible as ancestors of the tag. So you can undo the rebase with reset --hard feature-with-merge A better-practice for testing with updates from main is to have a feature-testing branch with merges from both branches. This is called "throwaway merging" in the documentation. When you see significant merge conflicts (number or difficulty) that's when you have to consider rebasing the feature branch to include upstream changes. Interactive rebase can also solve your problem because it's a very general "rewind changes and do stuff with them." But rebasing merges is an extra layer of complexity that I wouldn't recommend. The better way to learn rebase -i, and the more common way to use it, is to revise your change history before sharing it. When you're working on something it's fine to make changes in a stream-of-consciousness order, typo the commit messages, try something and need to revert it. Interactive rebase allows you to redo your development changes in a different order or organized differently. More on reddit.com
🌐 r/git
2
1
October 4, 2022
How to undo a Git merge that hasn't been pushed yet?
Instead of rewriting history, ... that undoes the changes introduced by the merge commit. ... Use git log to find the merge commit you want to revert. ... Here, a1b2c3d is the merge commit. ... Use the git revert command with the -m flag to specify the parent number. In most cases, -m 1 is used to keep the changes from the main branch and revert the feature branch's changes. ... If the revert introduces conflicts, resolve them ... More on designgurus.io
🌐 designgurus.io
1
10
November 2, 2024
🌐
Git Tower
git-tower.com › learn › git › ebook › en › command-line › advanced-topics › merge-conflicts
Dealing With Merge Conflicts | Learn Git Ebook (CLI Edition)
In case you've made a mistake while resolving a conflict and realize this only after completing the merge, you can still easily undo it: just roll back to the commit before the merge happened with "git reset --hard
🌐
Baeldung
baeldung.com › home › git › git merging: conflict resolution and undoing a merge
Git Merging: Conflict Resolution and Undoing a merge | Baeldung on Ops
July 6, 2024 - When controlling file versioning with Git, there are times when we need to resolve differences between separate versions of the same file. This is often the case during a merge operation. However, we might perform a merge by mistake. In this tutorial, we discuss Git merging and how to revert or undo a merge. First, we establish a sample repository. After that, we briefly refresh our knowledge about the merge subcommand and its mechanics. Next, we turn to conflict ...
🌐
Codemia
codemia.io › knowledge-hub › path › how_to_undo_a_git_merge_with_conflicts
How to undo a git merge with conflicts
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
🌐
Git Tower
git-tower.com › learn › git faq › how to undo a merge in git
How to undo a merge in Git | Learn Version Control with Git
1 day ago - Whatever the case may be, undoing a merge is simply a matter of executing a few commands. In this short article, we'll discuss how to undo a merge: With the "git reset" command: for merges that have only occurred in your local repository.
Find elsewhere
🌐
YouTube
youtube.com › watch
How to cancel or undo git pull merge conflicts
Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.
🌐
Graphite
graphite.com › guides › how-to-undo-a-git-merge
How to undo a git merge - Graphite
If you resolved a merge conflict but are not satisfied with the resolution, you can undo it before committing by using: ... This command will reset your working directory to the last committed state. If you have merged branches and encountered conflicts that you haven't resolved yet, or you decide you don't want to proceed with the merge before committing, use: ... This command cancels the merge operation and returns your branch to its pre-merge state. Sometimes, you might execute a git pull that results in an unwanted merge.
🌐
Unfuddle
unfuddle.com › stack › tips-tricks › git-cancel-merge
Unfuddle Support | Git - Cancel Merge
Use git-reset or git merge --abort to cancel a merge that had conflicts. # Reset all the changes back to the last commit. # Note: This cannot be reverted! $ git reset --hard HEAD # OR $ git merge --abort · Please note that all the changes will ...
🌐
DataCamp
datacamp.com › tutorial › git-revert-merge
Git Revert Merge Commit: A Guide With Examples | DataCamp
November 5, 2024 - Resolve the conflicts: We open each conflicting file, resolve the conflicts marked by Git, and save the changes. ... Using git revert to undo merge commits ensures that every change and correction is documented within the commit history.
🌐
CoreUI
coreui.io › answers › how-to-undo-git-merge
How to undo git merge · CoreUI
January 15, 2026 - Use git merge --abort during conflicts to cancel in-progress merges. Use git reset --hard HEAD~1 to undo local merges before pushing. Use git revert -m 1 for pushed merges to maintain history.
🌐
GitKraken
gitkraken.com › home › learn › problems & solutions › how do you undo a git merge?
How do you undo a Git merge? | Solutions to Git Problems
February 7, 2025 - If this is the case, move forward with the git reset command. ... GitTip: If you happen to have any uncommitted changes, be sure to use the Git stash command before running Git reset.
🌐
Reddit
reddit.com › r/git › help fixing bad conflict resolution
r/git on Reddit: Help fixing bad conflict resolution
October 4, 2022 -

I have a feature branch only I'm working on.

I made a merge from master into my feature branch, to keep it up-to-date, and accidentally solved conflicts wrong.

Kept working on my feature and pushed more changes. How can I revert things to: not bring in the bad "resolved conflicts" into my feature branch?

Essentially what I want to do is to make sure I am in my current branch in the following state:

1/ exactly as I was before I did the bad merge conflict resolution ;

And

2/ somehow I want to be able to, from the state I'll be after doing 1,still apply the changes I've done after my bad merge, maybe using a cherry pick on each individual commit or something...

I read that maybe an interactive rebase can be what I need but I've never done it.... Any help appreciated

Top answer
1 of 2
2
Find and temporary tag your merge commit. (merged) Tag the current tip of your feature branch so that you can retry if you mess up. (feature-with-merge) Then the commit just before then is called either merged^1 or merged^2 depending on which direction you ran the merge. ^1 is more likely. The rebase command needs to rewind all commits after the merge and reapply them just before. That's rebase merged --onto merged^1 Which means "rewind to the common ancestor with merged then go to its first parent then replay the rewound changes. Rewinding means that the tip of branch pointer feature moves backwards and abandons commits. But those commits (merge then develop) will still be accessible as ancestors of the tag. So you can undo the rebase with reset --hard feature-with-merge A better-practice for testing with updates from main is to have a feature-testing branch with merges from both branches. This is called "throwaway merging" in the documentation. When you see significant merge conflicts (number or difficulty) that's when you have to consider rebasing the feature branch to include upstream changes. Interactive rebase can also solve your problem because it's a very general "rewind changes and do stuff with them." But rebasing merges is an extra layer of complexity that I wouldn't recommend. The better way to learn rebase -i, and the more common way to use it, is to revise your change history before sharing it. When you're working on something it's fine to make changes in a stream-of-consciousness order, typo the commit messages, try something and need to revert it. Interactive rebase allows you to redo your development changes in a different order or organized differently.
2 of 2
1
The faulty conflict resolution is part of the merge commit. To drop the merge commit using an interactive rebase, check the log for the commit hash of the merge commit and do this: git rebase -i ^ (mind the caret after the hash, this refers to the first parent commit) Git will open a file called "git-rebase-todo" in your default editor that will look like this: pick Merge master into xxy ... pick further commit 1 pick further commit 2 ... To remove a commit, you can delete a line here; do so with the merge commit. Save the file end close the editor. Git will then proceed to apply each commit that happened after the merge commit on top of the first parent commit of the merge commit. Mind that this could also lead to new conflicts you'll have to solve.
🌐
LabEx
labex.io › tutorials › git-reversing-a-git-merge-step-by-step-400129
Reversing a Git Merge Step-by-Step | LabEx
You will learn how to resolve merge conflicts and undo the entire merge operation, allowing you to effectively manage your Git repository history. Whether you're a seasoned Git user or new to the version control system, this guide will provide you with the necessary knowledge to handle unwanted ...
Top answer
1 of 1
10
Undoing a Git merge that hasn't been pushed to a remote repository is a common task, especially when you realize that the merge introduced unwanted changes, conflicts that are too complex to resolve, or simply wasn't the right time to integrate the branches. Git provides several methods to revert or undo a merge, depending on the state of your repository at the time you decide to undo the merge. This comprehensive guide will walk you through the various scenarios and methods to undo a Git merge that hasn't been pushed yet, ensuring you can safely and effectively manage your repository's history. Table of Contents Understanding the Merge Scenarios Prerequisites Method 1: Aborting an Ongoing Merge Method 2: Resetting to a Previous Commit After a Completed Merge Method 3: Using git reflog to Locate and Reset to a Previous State Method 4: Reverting a Merge Commit Best Practices and Considerations Example Scenarios Troubleshooting Common Issues Additional Resources Understanding the Merge Scenarios Before diving into the methods, it's crucial to understand the different states your repository might be in after initiating a merge: Merge in Progress (Conflicts Unresolved): You started a merge, encountered conflicts, and haven't resolved them yet. Merge Completed (Commit Made): You successfully completed the merge by resolving conflicts and creating a merge commit. Merge Completed (Fast-Forward): The merge was a fast-forward, meaning no actual merge commit was created because the branch was directly ahead. Merge via Rebase or Other Operations: You used operations like git pull --rebase which involve merging changes in a different manner. Each scenario requires a slightly different approach to undo the merge effectively. Prerequisites Ensure that you have: Git Installed: Verify by running git --version. If not installed, download it from the official Git website. Navigated to Your Repository: Use cd path/to/your/repository to navigate to the Git repository where the merge occurred. Backup Important Changes: Before performing operations that rewrite history or alter commits, consider creating a backup branch to prevent accidental data loss. git branch backup-branch Method 1: Aborting an Ongoing Merge Use Case: You initiated a merge (git merge ) but encountered conflicts and decide you want to cancel the merge process before completing it. Steps: Check the Merge Status: Ensure that a merge is indeed in progress. git status Sample Output: On branch feature-branch You have unmerged paths. (fix conflicts and run "git commit") (use "git merge --abort" to abort the merge) Unmerged paths: both modified: src/app.js Abort the Merge: Use the git merge --abort command to stop the merge process and revert to the state before the merge began. git merge --abort Alternative Command: If git merge --abort doesn't work or isn't available, you can use: git reset --merge Verify the Abortion: After aborting, check the repository status to ensure the merge has been canceled. git status Expected Output: On branch feature-branch Your branch is up to date with 'origin/feature-branch'. nothing to commit, working tree clean
🌐
Reddit
reddit.com › r/git › how to reset a broken conflict merge on a branch?
r/git on Reddit: How to reset a broken conflict merge on a branch?
November 11, 2014 -

Somebody who was working on a branch did a pull from master with several conflicts. His resolves were completely broken. He committed and pushed.

What is the best way to roll back before the merge to resolve again? My best solution was:

  • reset local branch hard

  • delete remote branch

  • push again

Is there a better way?

PS: We use Tortoise for Windows (in case there is a nice graphical solution)

🌐
Graph AI
graphapp.ai › blog › how-to-undo-a-merge-in-git
How to Undo a Merge in Git | Graph AI
There are times in Git when you ... Fortunately, Git provides us with two commonly used methods to undo a merge: using Git reset and using Git revert....
🌐
JanBask Training
janbasktraining.com › community › devops › undo-git-stash-pop-that-results-in-merge-conflict
Undo git stash pop that results in merge conflict | JanBask Training Community
April 13, 2021 - If you have run git stash pop and encountered merge conflicts, you can undo this operation to revert to the state before the stash was popped. Here’s a step-by-step guide to handle this situation: ... First, ensure you are aware of the current state of your working directory and index. ... If you prefer to resolve conflicts manually, you can proceed with resolving the conflicts in the files indicated by Git and then commit the changes.