Re: [DRAFT] Branching and merging with git

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Junio C Hamano
Date: Wednesday, November 22, 2006 - 4:51 am

Junio C Hamano <junkio@cox.net> writes:


I actually remembered a better one.

        Subject: Necessity of "evil" merge and topic branches
        Date: Wed, 17 May 2006 23:25:55 -0700
        Message-ID: <7vy7wz6e8c.fsf@assigned-by-dhcp.cox.net>

This talks about a real-world evil merge and the reason why it
was necessary, and speculates a possible way to make life
easier.  I actually later used the "third branch to remember the
evil merge between two topics" technique I talked about in the
message to merge in another pair of topics, and it turned out
that it worked rather well.

There were two logically independent topics:

 - lt/setup.  Two commits, changing the calling convention of
   setup_git_directory() function -- the final tip of the topic
   was at a633fca0.

 - js/mv.  Three commits, making git-mv a built-in after
   refactoring some code from other parts of the system -- the
   final tip of the topic was at ac64a722).

They were not "obviously correct" when they started, so a topic
branch was used for each.  They had textually and semantically
some conflicts, and if they were to progress at different paces,
there was a need for an evil merge when the later one is merged
to master.

So I created another branch to merge the two topics together and
resolved their conflicts while my reading of their code were
still fresh.

	git checkout -b __/setup-n-mv js/mv
        git pull . lt/setup
	git checkout next
        git pull . __/setup-n-mv

Later js/mv became ready to be merged first.  So I merged it to
'master'.

	git checkout master
        git pull . js/mv

I was planning to cook lt/setup a bit longer but eventually
decided to merge it to 'master' as well after a short while.

	git checkout master
        git pull . __/setup-n-mv

I could have pulled lt/setup into master but then I would have
had to resolve the conflict between the two branches.  Since I
recorded the resolution earlier by making the merge, and pulled
that branch (which contained all of lt/setup already) into
'master', I did not have to remember what I need to adjust when
I did so.  If lt/setup had further updates on its own after the
"third branch __/setup-n-mv" was made, I would have then pulled
the tip of lt/setup into 'master' to complete the merge, and
that would have also resulted in non-conflicting simple merge.

This would have worked equally well if lt/setup were to graduate
first.

This might look too complex at the first look, but I thought it
might be an interesting topic in the "hints for managing your
topic branches" section.

-
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
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[DRAFT] Branching and merging with git, linux, (Thu Nov 16, 3:17 pm)
Re: [DRAFT] Branching and merging with git, Junio C Hamano, (Thu Nov 16, 4:47 pm)
Re: [DRAFT] Branching and merging with git, Junio C Hamano, (Thu Nov 16, 6:09 pm)
Re: [DRAFT] Branching and merging with git, linux, (Thu Nov 16, 6:13 pm)
Re: [DRAFT] Branching and merging with git, Junio C Hamano, (Thu Nov 16, 6:31 pm)
Re: [DRAFT] Branching and merging with git, linux, (Thu Nov 16, 8:17 pm)
Re: [DRAFT] Branching and merging with git, Junio C Hamano, (Thu Nov 16, 10:55 pm)
Re: [DRAFT] Branching and merging with git, Theodore Tso, (Fri Nov 17, 8:32 am)
Re: [DRAFT] Branching and merging with git, Sean, (Fri Nov 17, 8:57 am)
Re: [DRAFT] Branching and merging with git, Nguyen Thai Ngoc Duy, (Fri Nov 17, 9:19 am)
Re: [DRAFT] Branching and merging with git, Marko Macek, (Fri Nov 17, 9:25 am)
Re: [DRAFT] Branching and merging with git, Petr Baudis, (Fri Nov 17, 9:33 am)
Re: [DRAFT] Branching and merging with git, Sean, (Fri Nov 17, 9:34 am)
Re: [DRAFT] Branching and merging with git, J. Bruce Fields, (Fri Nov 17, 10:44 am)
Re: [DRAFT] Branching and merging with git, J. Bruce Fields, (Fri Nov 17, 11:21 am)
Re: [DRAFT] Branching and merging with git, linux, (Fri Nov 17, 5:13 pm)
Re: [DRAFT] Branching and merging with git, Junio C Hamano, (Fri Nov 17, 5:40 pm)
Re: [DRAFT] Branching and merging with git, Junio C Hamano, (Fri Nov 17, 6:11 pm)
Re: [DRAFT] Branching and merging with git, J. Bruce Fields, (Sun Nov 19, 10:50 am)
Git manuals, Petr Baudis, (Sun Nov 19, 10:59 am)
Re: Git manuals, J. Bruce Fields, (Sun Nov 19, 12:36 pm)
[DRAFT 2] Branching and merging with git, linux, (Mon Nov 20, 4:51 pm)
Re: [DRAFT] Branching and merging with git, Junio C Hamano, (Wed Nov 22, 4:51 am)
[PATCH] Documentation: add a &quot;git user's manual&quot;, J. Bruce Fields, (Sat Nov 25, 9:01 pm)
Re: [DRAFT 2] Branching and merging with git, J. Bruce Fields, (Sun Dec 3, 6:19 pm)
Re: [DRAFT 2] Branching and merging with git, J. Bruce Fields, (Mon Dec 4, 12:23 am)
Re: [DRAFT 2] Branching and merging with git, Johannes Schindelin, (Mon Dec 4, 3:56 am)
Re: [DRAFT] Branching and merging with git, Theodore Tso, (Wed Jan 3, 10:04 am)
Re: [DRAFT] Branching and merging with git, Junio C Hamano, (Wed Jan 3, 10:08 am)
Re: [DRAFT] Branching and merging with git, linux, (Wed Jan 3, 10:28 pm)
Re: [DRAFT] Branching and merging with git, Junio C Hamano, (Wed Jan 3, 11:11 pm)
Re: [DRAFT] Branching and merging with git, J. Bruce Fields, (Sun Jan 7, 4:44 pm)
Re: [DRAFT] Branching and merging with git, Junio C Hamano, (Sun Jan 7, 5:24 pm)
Re: [DRAFT] Branching and merging with git, Theodore Tso, (Sun Jan 7, 5:40 pm)
Re: [DRAFT] Branching and merging with git, J. Bruce Fields, (Sun Jan 7, 5:46 pm)
Re: [DRAFT] Branching and merging with git , Horst H. von Brand, (Sun Jan 7, 6:46 pm)
Re: [DRAFT] Branching and merging with git, J. Bruce Fields, (Sun Jan 7, 7:22 pm)
Re: [DRAFT] Branching and merging with git, J. Bruce Fields, (Sun Jan 7, 7:35 pm)
Re: [DRAFT] Branching and merging with git, Guilhem Bonnefille, (Mon Jan 8, 5:38 am)
Re: [DRAFT] Branching and merging with git, Theodore Tso, (Mon Jan 8, 7:03 am)
Re: [DRAFT] Branching and merging with git, J. Bruce Fields, (Mon Jan 8, 7:41 pm)
Re: [DRAFT] Branching and merging with git, J. Bruce Fields, (Mon Jan 8, 9:17 pm)
Re: [DRAFT] Branching and merging with git, Andreas Ericsson, (Tue Jan 9, 1:46 am)
Re: [DRAFT] Branching and merging with git, J. Bruce Fields, (Tue Jan 9, 8:49 am)
Re: [DRAFT] Branching and merging with git, Theodore Tso, (Tue Jan 9, 9:58 am)
Re: [DRAFT] Branching and merging with git, J. Bruce Fields, (Tue Jan 9, 9:15 pm)