# Question about about a trivial merge conflict that git should resolve alone

2 messages from 2015-10-23 to 2015-10-23. Participants: Francis Moreau, Johannes Schindelin.
Thread: https://gitlist.dev/t/40623

## Francis Moreau, 2015-10-23 13:07

Subject: Question about about a trivial merge conflict that git should resolve alone
Message-ID: <CAC9WiBj7Vwfjzbik7+d9cxpS=m+_s-CViJ3b4fKAzYQ4ixXfiw@mail.gmail.com>
URL: https://gitlist.dev/e/CAC9WiBj7Vwfjzbik7%2Bd9cxpS%3Dm%2B_s-CViJ3b4fKAzYQ4ixXfiw%40mail.gmail.com

```
Hi,

I have a simple merge conflict use case:

$ mkdir foo
$ cd foo/
$ git init
$ echo line1 > a
$ git add .
$ git commit -q -m init
$ echo line2 >>a
$ git commit -a -q -m "add line2"
$ git checkout -b foo HEAD~1
$ git cherry-pick -x master
$ echo line3 >>a
$ git stage a
$ git commit -q -m "add line3"
$ git checkout master
$ git merge foo
$ git diff
diff --cc a
index c0d0fb4,83db48f..0000000
--- a/a
+++ b/a
@@@ -1,2 -1,3 +1,6 @@@
line1
line2
++<<<<<<< HEAD
++=======
+ line3
++>>>>>>> foo

Why does git think there's a conflict here since the "line2" string
was added in both branch by the same commit ?

Thanks.
-- 
Francis

```

## Johannes Schindelin, 2015-10-23 14:52

Subject: Re: Question about about a trivial merge conflict that git should resolve alone
Message-ID: <alpine.DEB.1.00.1510231651270.31610@s15462909.onlinehome-server.info>
URL: https://gitlist.dev/e/alpine.DEB.1.00.1510231651270.31610%40s15462909.onlinehome-server.info
In-Reply-To: <CAC9WiBj7Vwfjzbik7+d9cxpS=m+_s-CViJ3b4fKAzYQ4ixXfiw@mail.gmail.com>

```
Hi Francis,

On Fri, 23 Oct 2015, Francis Moreau wrote:

> I have a simple merge conflict use case:
> 
> $ mkdir foo
> $ cd foo/
> $ git init
> $ echo line1 > a
> $ git add .
> $ git commit -q -m init
> $ echo line2 >>a
> $ git commit -a -q -m "add line2"
> $ git checkout -b foo HEAD~1
> $ git cherry-pick -x master
> $ echo line3 >>a
> $ git stage a
> $ git commit -q -m "add line3"
> $ git checkout master
> $ git merge foo
> $ git diff
> diff --cc a
> index c0d0fb4,83db48f..0000000
> --- a/a
> +++ b/a
> @@@ -1,2 -1,3 +1,6 @@@
> line1
> line2
> ++<<<<<<< HEAD
> ++=======
> + line3
> ++>>>>>>> foo
> 
> Why does git think there's a conflict here since the "line2" string
> was added in both branch by the same commit ?

This is intentional, because what actually happens is that Git figures out
that line2 & line3 were added in one branch, but only line2 in the other,
and it helpfully reduces the conflict to the difference between the two.

The rationale is that you do not know which version is correct: was line2
sufficient, or do you really also need line3?

Ciao,
Johannes

```
