git: mergetool outputs 'No files need merging' while git rerere enabled
When rerere
(reuse recorded resolution) is enabled in git, it records how
you resolve conflicts and applies recorded resolutions upon same
conflicts.
I was trying different merge tools and using the same repository to try these tools. After resolving the conflict with one tool, changing my default tool, and reproducing the conflict scenario, git told me there are no files to merge. It took me some time to realize that I have enabled reuse recorded resolution, so every time merge the same branch, the recorded resolution is applied. But the status of merge was not changed.
If you happen to fall in to this situation, check your files with conflict; if
there are no merge conflict characters (like <<<<<<<<<<<<
) the conflict is
automatically resolved.
Then I saw the output of merge says Resolved 'file' using previous resolution
. After digging into merge
documentation (git help merge
), I saw the --rerere-autoupdate
option:
--[no-]rerere-autoupdate
Allow the rerere mechanism to update the index with the result of auto-conflict resolution possible.
If we run git merge branch-name --rerere-autoupdate
, git stops while merging but this time the output says: Staged 'file' using previous resolution
. The resolved file is automatically added to staged area with this option, so we can continue to git commit
without doing anything: