Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to undo a merge (without commit)?

I just did an svn merge to merge changes from the trunk to a branch:

$ svn merge -r328:HEAD file:///home/user/svn/repos/proj/trunk . --- Merging r388 through r500 into '.': A    foo A    bar    C baz1    C baz2 U    duh [...] 

But there were too many conflicts, so I'd like to undo that.

One way to do that is to commit and then merge back. But I can't commit because of the conflicts. What's the best way to undo in that case?

like image 316
Frank Avatar asked Dec 13 '09 16:12

Frank


People also ask

How do I undo a merge in git?

Use git-reset or git merge --abort to cancel a merge that had conflicts. Please note that all the changes will be reset, and this operation cannot be reverted, so make sure to commit or git-stash all your changes before you start a merge.

How do I undo a merge attempt?

Git merge --abort # this will allow you to undo merge conflicts. 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, Generally, you shouldn't merge with uncommitted changes anyway.

How do I undo a pushed merge commit?

simply run git reset --hard to revert all those changes.


1 Answers

Revert recursively from the top of your working copy:

svn revert -R .

You will need to manually delete the files that were added. As in after reverting, the files added will remain on disk but they will be in a non-tracked state ("? foo")

like image 99
richq Avatar answered Oct 04 '22 11:10

richq