Unexpected git diff output during merge conflict
- From
- Nick O'Leary <nick.oleary@gmail.com>
- Date
- Feb 8, 2018, 10:51 UTC
- Message-ID
- <CAF=vhqdJ2fByjSVt37b34wQUFo5_tb7rHbCddsaCzdvKywSBdg@mail.gmail.com>
Hi,
I have a merge conflict on a file and the git diff output looks wrong to me.
Here's how to recreate:
On branch 'dev' add/commit a file (called README.md) with the contents ( '------' used to delimit the file, not included in the content):
------- This is my default readme -------
On branch 'master' add/commit the same file with the contents:
------- merged-history-test ===================
### About
This is your project's README.md file. It helps users understand what your project does, how to use it and anything else they may need to know. -------
Then, whilst on master, run `git merge dev` and get the inevitable merge conflict on this file.
Running `git diff README.md` gives:
$ git diff README.md diff --cc README.md index 61d78b2,620d806..0000000
--- a/README.md +++ b/README.md @@@ -1,7 -1,1 +1,11 @@@ -This is my default readme ++<<<<<<< HEAD +merged-history-test +=================== + +### About + +This is your project's README.md file. It helps users understand what your - project does, how to use it and anything else they may need to know. ++project does, how to use it and anything else they may need to know. ++======= ++This is my default readme ++>>>>>>> dev This does not look right to me. The 'This is my default readme' line has ++ at the start - suggesting its new to both parent copies of the file, which isn't the case - it came from the dev branch so should be prefixed with '+ '. I'm also not clear why the line beginning 'project does' has both a - and ++ prefix. In every description of the Combined Diff format that I've been able to find, they only show having '+ ' or ' +' prefixes on the actual content and '++' on the <<<</=====/>>>> lines. Am I missing something here? Thanks, Nick