Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git says "No files need merging" immediately after a merge conflict

Tags:

git

git-rerere

For example

> git cherry-pick <hash>
...
error: could not apply <hash>...
Resolved '<file>' using previous resolution.
> git mergetool
No files need merging
> git status
...
Unmerged paths:
  (use "git add <file>..." to mark resolution)

    both modified: <file>

"both modified" and "No files need merging"? liar!

like image 307
jozxyqk Avatar asked Nov 02 '25 16:11

jozxyqk


1 Answers

I'm guessing the problem is somehow git rerere got hold of a bad merge. I think this often happens when meld doesn't quite realise I've pressed Ctrl-S and it records conflict markers into the resolution. Why git still says "both modified" and doesn't allow mergetool to run I don't know. Anyway the fix is as follows:

git rerere forget <file>
git checkout -m <file>
git mergetool

I wish git checkout -m would imply git rerere forget or git status was more explicit. Would have saved a whole bunch of time.

like image 198
jozxyqk Avatar answered Nov 04 '25 08:11

jozxyqk