[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: tracking two git branches at once
From: |
Johannes Schindelin |
Subject: |
Re: tracking two git branches at once |
Date: |
Sat, 3 Mar 2007 14:38:20 +0100 (CET) |
Hi,
On Fri, 2 Mar 2007, Graham Percival wrote:
> Most of the time I track master. I have the documentation built, so
> whenever I make a change it only takes a few minutes to compile the
> changed the files.
>
> Occasionally I want to make a one-line change to web/master. If I just
> do "git checkout web/master", then I get a weird mixture of master and
> web/master (because git doesn't remove my Documentation/ because I have
> compiled files in there). I can avoid this weird mixture by deleting
> all the files before checking out the new branch, but then when I go
> back to master, it takes me an hour to compile all the docs. As a
> result, I tend to wait for a week or two before making changes to
> web/master.
>
> Can I have a pair of directories like
> lily-main/master
> lily-main/web
>
> which track different branches of git? (ie without downloading all
> changes twice)
Hm. That's certainly a _bit_ cumbersome with Git. However, it is possible.
If you bear with me for a few minutes, you can make yourself a fine script
and it will be easy for you (after writing that script).
The idea I have in mind is to use a local clone. Git makes this very easy,
and even efficient: if you clone with "git clone -l -s -n . my-web", you
will have a clone (of the repository you are currently working in) in
my-web/.
The option "-l" says that this is a local clone, which makes it fast. The
option "-s" tells Git to reuse the object database, so it makes it
inexpensive in terms of disk space. And "-n" says that Git should not
checkout a branch (otherwise it would checkout the master branch of the
source repository, which is your current one).
So, after creating this clone, you have to cd into my-web/ and say "git
checkout web/master".
You might want to copy the "remote" information (the shortcuts for fetch
and push) from the "master" repository to the "my-web" repository. I'd
just copy & paste the relevant parts from master/.git/config to
my-web/.git/config.
The real problem is that you should always fetch from your first
repository, and then fetch from _that_ into my-web/. You _can_ fetch from
savannah into my-web/ directly, and it works just as expected, _except_
that the objects are now stored in my-web/.git/. The next time you fetch
from savannah into your "master" repository, you will have the objects
_twice_.
In practice, however, this might not be the problem I made it sound like.
BTW your use case is a perfect demonstration that the "distributed" in
distributed SCMs not only benefits a _group_ of developers, but already a
single one!
Ciao,
Dscho