Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

undoing git merge after merge.renameLimit warning plus conflicts

I am trying to do a merge squash from a devel branch into the master.

stefanos-imac:trunk borini$ git merge --squash devel
CONFLICT (content): Merge conflict in test1
warning: inexact rename detection was skipped due to too many files.
warning: you may want to set your merge.renamelimit variable to at least 2224 and retry the command.
Squash commit -- not updating HEAD
Automatic merge failed; fix conflicts and then commit the result.

fair enough.

stefanos-imac:trunk borini$ git config merge.renameLimit 999999

Then I try to undo the merge and redo it with the higher limit

stefanos-imac:trunk borini$ git merge --abort
fatal: There is no merge to abort (MERGE_HEAD missing).

Ok, so maybe I have to do as it says and just reinvoke the merge command

stefanos-imac:trunk borini$ git merge --squash devel
fatal: 'merge' is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>' as
appropriate to mark resolution and make a commit, or use 'git commit -a'.

oh git, why are you such a git?

More to the point, does anyone know how to get out of this situation ?

like image 598
Stefano Borini Avatar asked May 24 '12 12:05

Stefano Borini


3 Answers

Em, git reset --hard origin/master?

like image 121
holygeek Avatar answered Oct 19 '22 09:10

holygeek


The modern way to undo a merge is (but this only works when MERGE_HEAD is present):

git merge --abort

And the slightly older way, which will work in this case (MERGE_HEAD is missing):

git reset --merge

The old-school way described in accepted answer (warning: will discard all your local changes):

git reset --hard

So notice that git merge --abort is only equivalent to git reset --merge given that MERGE_HEAD is present. This can be read in the git help for merge command.

git merge --abort is equivalent to git reset --merge when MERGE_HEAD is present.

After a failed merge, when there is no MERGE_HEAD, the failed merge can be undone with git reset --merge but not necessarily with git merge --abort.

like image 39
Martin G Avatar answered Oct 19 '22 07:10

Martin G


git merge --abort will also do the trick. A bit quicker than typing the full git reset command.

Abort also works with rebase and cherry-pick.

like image 4
PeloNZ Avatar answered Oct 19 '22 08:10

PeloNZ