Why doesn't git diff show anything for unmerged paths
During a merge, the conflicting files are in a special state. There exists multiple entries with the same filename and different blob id's. These are usually three blobs (used for the three way merge) or two blobs (for a simple merge).
Attempt the merge..
$ git merge origin/otherbranch
Merge remote-tracking branch 'origin/otherbranch' into mybranch
Conflicts:
somefile.txt
Review the files which need merging
$ git diff --name-status --diff-filter=U
U somefile.txt
or
$ git update-index --refresh
somefile.txt: needs merge
Review the blobs which relate to the file being merged;
$ git ls-files -s somefile.txt
100644 9a0579524e0c7ba9fc9ae18badadaddcad2d598f **1** somefile.txt
100644 1bcff16b6de5ed304a06e643070e40787db1ead8 **2** somefile.txt
100644 6e52271b22f6a6d1150619433551e0fa9094b108 **3** somefile.txt
According to the git-merge man-page. 1 = common ancenstor, 2 = HEAD (ours) and 3 = MERGE_HEAD (theirs)
Show differences
$ git diff 9a0579524e0c7ba9fc9ae18badadaddcad2d598f 6e52271b22f6a6d1150619433551e0fa9094b108
< some differences >
Retrieve the common ancestor..
$ git cat-file blob 9a0579524e0c7ba9fc9ae18badadaddcad2d598f
Checkout version from HEAD
$ git checkout --ours somefile.txt
checkout version from MERGE_HEAD
$ git checkout --theirs somefile.txt
Reset to 'merged' changed
$ git checkout -m somefile.txt
The only way I'm able to see the changes for conflict files is:
git diff --merge <unmerged-file>