# How do git recognize conflicts?

4 messages from 2024-09-05 to 2024-09-06. Participants: KwonHyun Kim, Johannes Sixt.
Thread: https://gitlist.dev/t/62064

## KwonHyun Kim, 2024-09-05 14:10

Subject: How do git recognize conflicts?
Message-ID: <CADLV-7K-D8ydFfeojv7EuhxBqKWsVYLofXJji+Y5rUTA8JEQ7w@mail.gmail.com>
URL: https://gitlist.dev/e/CADLV-7K-D8ydFfeojv7EuhxBqKWsVYLofXJji%2BY5rUTA8JEQ7w%40mail.gmail.com

```
 Hi, there.

 At first, I thought it's determined by line.

 But as I experimented, it does not look so.

 Here's what I experimented

 merge-base ====

 hi all

 branch BrA ===

 hi everyone

 branch BrB ===

 hi all
 good to see you

 when I merge BrB from BrA, I get conflicts.

 but the first line is only changed in BrA,
 and BrB added a line so there is no reason to have a conflict...
 that's what i think

 and I wonder the algorithm how git recognizes the conflict... or how
git automerges...
 I searched internet, git documentation but to no avail.

 Thank you in advance

 KwH Kim

```

## Johannes Sixt, 2024-09-05 16:39

Subject: Re: How do git recognize conflicts?
Message-ID: <cbc0019a-682a-4cec-8a06-24b12060a692@kdbg.org>
URL: https://gitlist.dev/e/cbc0019a-682a-4cec-8a06-24b12060a692%40kdbg.org
In-Reply-To: <CADLV-7K-D8ydFfeojv7EuhxBqKWsVYLofXJji+Y5rUTA8JEQ7w@mail.gmail.com>

```
Am 05.09.24 um 16:10 schrieb KwonHyun Kim:
>  Hi, there.
> 
>  At first, I thought it's determined by line.
> 
>  But as I experimented, it does not look so.
> 
>  Here's what I experimented
> 
>  merge-base ====
> 
>  hi all
> 
>  branch BrA ===
> 
>  hi everyone
> 
>  branch BrB ===
> 
>  hi all
>  good to see you
> 
>  when I merge BrB from BrA, I get conflicts.
> 
>  but the first line is only changed in BrA,
>  and BrB added a line so there is no reason to have a conflict...
>  that's what i think

If the changes in the two branches are in adjacent lines, then that is
considered a conflict as well.

-- Hannes


```

## Johannes Sixt, 2024-09-06 07:03

Subject: Re: How do git recognize conflicts?
Message-ID: <39f85eac-c6af-444a-a514-ad7172748350@kdbg.org>
URL: https://gitlist.dev/e/39f85eac-c6af-444a-a514-ad7172748350%40kdbg.org
In-Reply-To: <CADLV-7K7uumH+ikT6B2H39XR-eX21xBzUSNbeyVv2wM2q1e=QQ@mail.gmail.com>

```
Please use "Reply to all" on this mailing list and please do not top-post.

Am 06.09.24 um 07:09 schrieb KwonHyun Kim:
>   Thank you for the answer,
> 
>   Is there any other exceptions from line-by-line change?
> 
>   Can I ask you of any reference?

Another "exception" would be a modify-delete conflict, i.e., where one
side modifies the file and the other deletes it.

Apart from that, you would have to dig into the source code.

-- Hannes

> 
> -- KwH Kim
> 
> 2024년 9월 6일 (금) 오전 1:39, Johannes Sixt <j6t@kdbg.org>님이 작성:
> 
>>
>> Am 05.09.24 um 16:10 schrieb KwonHyun Kim:
>>>  Hi, there.
>>>
>>>  At first, I thought it's determined by line.
>>>
>>>  But as I experimented, it does not look so.
>>>
>>>  Here's what I experimented
>>>
>>>  merge-base ====
>>>
>>>  hi all
>>>
>>>  branch BrA ===
>>>
>>>  hi everyone
>>>
>>>  branch BrB ===
>>>
>>>  hi all
>>>  good to see you
>>>
>>>  when I merge BrB from BrA, I get conflicts.
>>>
>>>  but the first line is only changed in BrA,
>>>  and BrB added a line so there is no reason to have a conflict...
>>>  that's what i think
>>
>> If the changes in the two branches are in adjacent lines, then that is
>> considered a conflict as well.
>>
>> -- Hannes
>>


```

## KwonHyun Kim, 2024-09-06 08:36

Subject: Re: How do git recognize conflicts?
Message-ID: <CADLV-7+YxrXX4iOA6dHMtv3gGxyy9FBbzCDQ2SkjejkyGe2iKQ@mail.gmail.com>
URL: https://gitlist.dev/e/CADLV-7%2BYxrXX4iOA6dHMtv3gGxyy9FBbzCDQ2SkjejkyGe2iKQ%40mail.gmail.com
In-Reply-To: <39f85eac-c6af-444a-a514-ad7172748350@kdbg.org>

```
  Sure, I am replying to all,

  Anyhow, modify-delete conflict seems to be a legitimate conflict to me...

  How come it is an exception to line-by-line conflicts(conflict only
when the same line is modified by both)?

  In one version some lines are modified and in the other version all
are deleted

  -- KwH Kim


2024년 9월 6일 (금) 오후 4:03, Johannes Sixt <j6t@kdbg.org>님이 작성:
>
> Please use "Reply to all" on this mailing list and please do not top-post.
>
> Am 06.09.24 um 07:09 schrieb KwonHyun Kim:
> >   Thank you for the answer,
> >
> >   Is there any other exceptions from line-by-line change?
> >
> >   Can I ask you of any reference?
>
> Another "exception" would be a modify-delete conflict, i.e., where one
> side modifies the file and the other deletes it.
>
> Apart from that, you would have to dig into the source code.
>
> -- Hannes
>
> >
> > -- KwH Kim
> >
> > 2024년 9월 6일 (금) 오전 1:39, Johannes Sixt <j6t@kdbg.org>님이 작성:
> >
> >>
> >> Am 05.09.24 um 16:10 schrieb KwonHyun Kim:
> >>>  Hi, there.
> >>>
> >>>  At first, I thought it's determined by line.
> >>>
> >>>  But as I experimented, it does not look so.
> >>>
> >>>  Here's what I experimented
> >>>
> >>>  merge-base ====
> >>>
> >>>  hi all
> >>>
> >>>  branch BrA ===
> >>>
> >>>  hi everyone
> >>>
> >>>  branch BrB ===
> >>>
> >>>  hi all
> >>>  good to see you
> >>>
> >>>  when I merge BrB from BrA, I get conflicts.
> >>>
> >>>  but the first line is only changed in BrA,
> >>>  and BrB added a line so there is no reason to have a conflict...
> >>>  that's what i think
> >>
> >> If the changes in the two branches are in adjacent lines, then that is
> >> considered a conflict as well.
> >>
> >> -- Hannes
> >>
>

```
