gitgit-mergegit-diff

How can I view manual changes so far in an ongoing merge?


In Git, my merge is still ongoing (no commit yet). 98% of the changes that show up in git diff are related to what MERGE_HEAD (and parent history singe merge-base) brought. 1% is my work from HEAD and the rest is some manual tweaks and fixes I had to make as part of the merge itself. How to find those? It's kind of like looking for a needle in a haystack. All variants on git diff yield changes coming from MERGE_HEAD:

git diff HEAD

git diff $(git merge-base HEAD MERGE_HEAD)

I don't know what to do.


Solution

  • If you don't want to see the changes between your target branch and the merge base (git diff HEAD), nor the modifications between the other branch and the merge base (git diff MERGE_HEAD), but only the edits you've made so far during the conflict resolution, you could run

    git diff AUTO_MERGE
    

    Quoting the AUTO_MERGE documentation in the Description section of git diff:

    A tree of interest is the one pointed to by the ref named AUTO_MERGE, which is written by the ort merge strategy upon hitting merge conflicts (see git-merge[1]). Comparing the working tree with AUTO_MERGE shows changes you’ve made so far to resolve textual conflicts