Re: Managing multiple branches in git

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Ron Mayer <rm_pg(at)cheapcomplexdevices(dot)com>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Mark Mielke <mark(at)mark(dot)mielke(dot)cc>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "David E(dot) Wheeler" <david(at)kineticode(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Managing multiple branches in git
Date: 2009-06-02 22:17:36
Message-ID: 603c8f070906021517g641367e9r906ca8ad76e40a4a@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jun 2, 2009 at 5:28 PM, Ron Mayer <rm_pg(at)cheapcomplexdevices(dot)com> wrote:
> Robert Haas wrote:
>> And, unfortunately, I'm not sure there's a good solution.  Tom could
>> create 1 local repository cloned from the origin and then N-1 copies
>> cloned with --local from that one, but this sort of defeats the
>> purpose of using git, because now if he commits a change to one of
>> them and then wants to apply that change to each back branch, he's got
>> to fetch that change on each one, cherry-pick it, make his changes,
>> commit, and then push it back to his main repository.  Some of this
>
> Why has he got to do this pushing back to his main?   How about
>
>  creating 1 local repository from Origin,
>  create N-1 cloned with --local from that one
>  for each of those "--local" ones, "git-remote add" the main origin
>
> From then ISTM his workflow is very similar to the way he does with CVS,
> pulling and pushing from those multiple repositories to the central
> origin.  He can creating the patches/diffs to apply to each the same
> way he does today.
>
> ISTM he'd mostly be unaware that these repositories were ever connected
> in some way unless he inspected that some of the files in .git had the
> same inodes because they came from hard links.

Well, that might work, depending on his workflow. Maybe I'm making
some assumptions here that aren't justified. Let's assume contrary to
fact that I am a committer and the master VCS for this project is git.
I need to fix something in the master branch and backport it to
REL8_3_STABLE and REL8_2_STABLE. I would probably do it like this:

git pull
git checkout master
<do my thing>
git commit -a
git checkout REL8_3_STABLE
git cherry-pick -nx master
<adjust patch>
git commit -a
git checkout REL8_2_STABLE
git cherry-pick -nx REL8_3_STABLE
<further adjust patch>
git commit -a
git push

Since I push all of my commits together, it's almost as if it's a
single commit - it is at any rate no worse than CVS, which is
non-atomic by nature. If I have multiple local git trees, I start
like this:

cd $HOME/pgsql/master
git pull
<do my thing>
git commit -a

...and now what? If there's any point to git, it's surely that it's
easy to move commits around, so I'd like to type a command here to
attempt to apply that commit to $HOME/pgsql/REL8_3_STABLE. Assuming
that tree is cloned from the other local tree, I think I need to do
this:

cd $HOME/pgsql/REL8_3_STABLE
git pull
git cherry-pick -nx master
<adjust patch>
git commit -a
git push

cd $HOME/pgsql/REL8_2_STABLE
git pull
git cherry-pick -nx REL8_3_STABLE
<adjust patch further>
git commit -a
git push

cd $HOME/pgsql/master
git push # all branches upstream for real

Now, maybe if Tom is happy to move around his patches the way he does
now, it doesn't matter: he can just have three clones from upstream
and move the patch around using diff and patch or whatever; then have
a shell script call push-em-all to do just that. I would not want to
do that, because the ability to move patches around easily between
branches is for me one of the biggest advantages of using git in the
first place, and having multiple local repositories dilutes that. But
what I want doesn't matter unless it happens to be the same thing Tom
wants.

...Robert

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Stark 2009-06-02 22:32:40 Re: Managing multiple branches in git
Previous Message David E. Wheeler 2009-06-02 22:16:19 Re: Managing multiple branches in git