Re: merge result
From: Matthieu Moy <hidden>
Date: 2016-06-15 22:52:01
Lynn Lin [off-list ref] writes:
quoted
quoted
1->2->3-4>5 Master | 4->6->7 AA 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/