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 ?
Em, git reset --hard origin/master
?
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
.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With