All of lore.kernel.org
 help / color / mirror / Atom feed
* merge result
@ 2011-09-09 10:54 Lynn Lin
  2011-09-09 12:41 ` Andrew Ardill
  2011-09-09 13:00 ` Matthieu Moy
  0 siblings, 2 replies; 6+ messages in thread
From: Lynn Lin @ 2011-09-09 10:54 UTC (permalink / raw)
  To: git

Hi All,
   When I merge branch A back to master branch,if there are same
commit(developer do double commit) both in master and A branch, there
will be two same commit in master branch.For example


   1->2->3-4>5        Master
       |
       4->6->7          A

When I merge A branch into master,the two same 4 commit will present
in master branch.

Is there any wrong with my operation?

Thanks for your help
Lynn

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: merge result
  2011-09-09 10:54 merge result Lynn Lin
@ 2011-09-09 12:41 ` Andrew Ardill
  2011-09-10  1:07   ` Lynn Lin
  2011-09-09 13:00 ` Matthieu Moy
  1 sibling, 1 reply; 6+ messages in thread
From: Andrew Ardill @ 2011-09-09 12:41 UTC (permalink / raw)
  To: Lynn Lin; +Cc: git

Hi Lynn,

If you merge two branches together you are merging the state of the
head of those trees, not re-applying commits on top of each other. The
changes introduced in commit 4 will therefore not be applied twice,
but will more-or-less be ignored.

Perhaps you are not trying a merge operation, but something else? Is
this issue hypothetical, or is it something you have experienced??

Regards,

Andrew Ardill



On 9 September 2011 20:54, Lynn Lin <lynn.xin.lin@gmail.com> wrote:
> Hi All,
>   When I merge branch A back to master branch,if there are same
> commit(developer do double commit) both in master and A branch, there
> will be two same commit in master branch.For example
>
>
>   1->2->3-4>5        Master
>       |
>       4->6->7          A
>
> When I merge A branch into master,the two same 4 commit will present
> in master branch.
>
> Is there any wrong with my operation?
>
> Thanks for your help
> Lynn
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: merge result
  2011-09-09 10:54 merge result Lynn Lin
  2011-09-09 12:41 ` Andrew Ardill
@ 2011-09-09 13:00 ` Matthieu Moy
  2011-09-10  1:11   ` Lynn Lin
  1 sibling, 1 reply; 6+ messages in thread
From: Matthieu Moy @ 2011-09-09 13:00 UTC (permalink / raw)
  To: Lynn Lin; +Cc: git

Lynn Lin <lynn.xin.lin@gmail.com> writes:

> Hi All,
>    When I merge branch A back to master branch,if there are same
> commit(developer do double commit) both in master and A branch, there
> will be two same commit in master branch.

They cannot be the "same" commit. They are different commits (i.e.
different sha1 identifier, and probably different trees), even though
they may have the same commit message and represent the same diff.

>    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.

If you really really want to avoid this duplication in the history, then
learn about rebase (which is both powerfull and dangerous, you've been
warned).

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: merge result
  2011-09-09 12:41 ` Andrew Ardill
@ 2011-09-10  1:07   ` Lynn Lin
  0 siblings, 0 replies; 6+ messages in thread
From: Lynn Lin @ 2011-09-10  1:07 UTC (permalink / raw)
  To: Andrew Ardill; +Cc: git

On Fri, Sep 9, 2011 at 8:41 PM, Andrew Ardill <andrew.ardill@gmail.com> wrote:
> Hi Lynn,
>
> If you merge two branches together you are merging the state of the
> head of those trees, not re-applying commits on top of each other. The
> changes introduced in commit 4 will therefore not be applied twice,
> but will more-or-less be ignored.
>
> Perhaps you are not trying a merge operation, but something else? Is
> this issue hypothetical, or is it something you have experienced??


1$ git checkout master
2$ git edit  and commit
3$ git checkout branchA
4$ git edit and commit
5$ git checkout master
6 $ git merge branchA

2 and 4 change is the same

> Regards,
>
> Andrew Ardill
>
>
>
> On 9 September 2011 20:54, Lynn Lin <lynn.xin.lin@gmail.com> wrote:
>> Hi All,
>>   When I merge branch A back to master branch,if there are same
>> commit(developer do double commit) both in master and A branch, there
>> will be two same commit in master branch.For example
>>
>>
>>   1->2->3-4>5        Master
>>       |
>>       4->6->7          A
>>
>> When I merge A branch into master,the two same 4 commit will present
>> in master branch.
>>
>> Is there any wrong with my operation?
>>
>> Thanks for your help
>> Lynn
>> --
>> To unsubscribe from this list: send the line "unsubscribe git" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: merge result
  2011-09-09 13:00 ` Matthieu Moy
@ 2011-09-10  1:11   ` Lynn Lin
  2011-09-10 11:35     ` Matthieu Moy
  0 siblings, 1 reply; 6+ messages in thread
From: Lynn Lin @ 2011-09-10  1:11 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: git

On Fri, Sep 9, 2011 at 9:00 PM, Matthieu Moy
<Matthieu.Moy@grenoble-inp.fr> wrote:
> Lynn Lin <lynn.xin.lin@gmail.com> writes:
>
>> Hi All,
>>    When I merge branch A back to master branch,if there are same
>> commit(developer do double commit) both in master and A branch, there
>> will be two same commit in master branch.
>
> They cannot be the "same" commit. They are different commits (i.e.
> different sha1 identifier, and probably different trees), even though
> they may have the same commit message and represent the same diff.
>
>>    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?


Thanks for your time to explain here and teach me

> If you really really want to avoid this duplication in the history, then
> learn about rebase (which is both powerfull and dangerous, you've been
> warned).
>
> --
> Matthieu Moy
> http://www-verimag.imag.fr/~moy/
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: merge result
  2011-09-10  1:11   ` Lynn Lin
@ 2011-09-10 11:35     ` Matthieu Moy
  0 siblings, 0 replies; 6+ messages in thread
From: Matthieu Moy @ 2011-09-10 11:35 UTC (permalink / raw)
  To: Lynn Lin; +Cc: git

Lynn Lin <lynn.xin.lin@gmail.com> writes:

>>>    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/

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-09-10 11:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-09 10:54 merge result Lynn Lin
2011-09-09 12:41 ` Andrew Ardill
2011-09-10  1:07   ` Lynn Lin
2011-09-09 13:00 ` Matthieu Moy
2011-09-10  1:11   ` Lynn Lin
2011-09-10 11:35     ` Matthieu Moy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.