git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: merge result

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
Sep 10, 2011, 11:35 UTC
Message-ID
<vpqr53oeijq.fsf@bauges.imag.fr>
In-Reply-To
<CAPgpnMTMPQQPkS-gKLvUJNKLfMWuAT-oA3NCiSRFxu7PknYsnA@mail.gmail.com>
Lynn Lin <lynn.xin.lin@gmail.com> writes:
Show 24 quoted lines
>>>    1->2->3-4>5        Master
>>>        |
>>>        4->6->7          A
>>
>> A more accurate drawing would be
>>
>>    1->2->3-4>5        Master
>>        |
>>        4'->6->7          A
>>
>> and after merging, you'd get
>>
>>    1->2->3-4>5-->8  A, master
>>        |       /
>>        4'->6->7
>>
>> with 8 having both 4 and 4' as ancestors. There's nothing wrong with it.
>> Git cannot remove either 4 or 4' without rewritting history, and "git
>> merge" does not rewrite history.
> so confused here.If 4' is just next 4 commit,how can the diff work? for example
>
> 1->2->4->4'->6->...
>
>  diff 4 and 4' is a little confused,correct?

History is not linear. When you type "git log", you may think that 4 and 4' follow each other, but try "gitk" or "git log --oneline --graph" to see a better view of history.

It's possible to have several times the same change applied to multiple branches (e.g. when doing cherry-picking), but having twice the same change in a row is not really possible.

Suppose your commit 4 removes the line "foobar". Then, commits 1, 2 and 3 have the line "foobar" (think of commits as snapshots in history, not as diff. 3 is a snapshot, and when you run "git show 3", it shows you the diff from 2 to 3). Commits 4 and 4' don't have it anymore, and then obviously 5, 6, 7 don't have it either. At the time of merge, Git will notice that neither of the merges to commit have the line "foobar" and the result 8 won't have it either.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: Lynn Lin
Message 6 of 6 in “merge result”
  1. Lynn LinSep 9, 2011
  2. Andrew ArdillSep 9, 2011
  3. Lynn LinSep 10, 2011
  4. Matthieu MoySep 9, 2011
  5. Lynn LinSep 10, 2011
  6. Matthieu MoySep 10, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.