{"thread":{"id":"40623","subject":"Question about about a trivial merge conflict that git should resolve alone","startedAt":"2015-10-23T13:07:39Z","lastAt":"2015-10-23T14:52:57Z","messageCount":2,"participants":["Francis Moreau","Johannes Schindelin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"272140","messageId":"CAC9WiBj7Vwfjzbik7+d9cxpS=m+_s-CViJ3b4fKAzYQ4ixXfiw@mail.gmail.com","threadId":"40623","inReplyTo":null,"subject":"Question about about a trivial merge conflict that git should resolve alone","fromName":"Francis Moreau","fromEmail":"francis.moro@gmail.com","sentAt":"2015-10-23T13:07:39Z","receivedAt":"2015-10-23T13:07:39Z","isPatch":false,"sender":{"key":"francis.moro@gmail.com","avatar":null},"body":"Hi,\n\nI have a simple merge conflict use case:\n\n$ mkdir foo\n$ cd foo/\n$ git init\n$ echo line1 > a\n$ git add .\n$ git commit -q -m init\n$ echo line2 >>a\n$ git commit -a -q -m \"add line2\"\n$ git checkout -b foo HEAD~1\n$ git cherry-pick -x master\n$ echo line3 >>a\n$ git stage a\n$ git commit -q -m \"add line3\"\n$ git checkout master\n$ git merge foo\n$ git diff\ndiff --cc a\nindex c0d0fb4,83db48f..0000000\n--- a/a\n+++ b/a\n@@@ -1,2 -1,3 +1,6 @@@\nline1\nline2\n++<<<<<<< HEAD\n++=======\n+ line3\n++>>>>>>> foo\n\nWhy does git think there's a conflict here since the \"line2\" string\nwas added in both branch by the same commit ?\n\nThanks.\n-- \nFrancis\n"},{"id":"272143","messageId":"alpine.DEB.1.00.1510231651270.31610@s15462909.onlinehome-server.info","threadId":"40623","inReplyTo":"CAC9WiBj7Vwfjzbik7+d9cxpS=m+_s-CViJ3b4fKAzYQ4ixXfiw@mail.gmail.com","subject":"Re: Question about about a trivial merge conflict that git should resolve alone","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2015-10-23T14:52:57Z","receivedAt":"2015-10-23T14:52:57Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Francis,\n\nOn Fri, 23 Oct 2015, Francis Moreau wrote:\n\n> I have a simple merge conflict use case:\n> \n> $ mkdir foo\n> $ cd foo/\n> $ git init\n> $ echo line1 > a\n> $ git add .\n> $ git commit -q -m init\n> $ echo line2 >>a\n> $ git commit -a -q -m \"add line2\"\n> $ git checkout -b foo HEAD~1\n> $ git cherry-pick -x master\n> $ echo line3 >>a\n> $ git stage a\n> $ git commit -q -m \"add line3\"\n> $ git checkout master\n> $ git merge foo\n> $ git diff\n> diff --cc a\n> index c0d0fb4,83db48f..0000000\n> --- a/a\n> +++ b/a\n> @@@ -1,2 -1,3 +1,6 @@@\n> line1\n> line2\n> ++<<<<<<< HEAD\n> ++=======\n> + line3\n> ++>>>>>>> foo\n> \n> Why does git think there's a conflict here since the \"line2\" string\n> was added in both branch by the same commit ?\n\nThis is intentional, because what actually happens is that Git figures out\nthat line2 & line3 were added in one branch, but only line2 in the other,\nand it helpfully reduces the conflict to the difference between the two.\n\nThe rationale is that you do not know which version is correct: was line2\nsufficient, or do you really also need line3?\n\nCiao,\nJohannes\n"}]}