[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tracking two git branches at once

From: Mats Bengtsson
Subject: Re: tracking two git branches at once
Date: Mon, 05 Mar 2007 10:22:07 +0100
User-agent: Thunderbird (X11/20061206)

I know very little about GIT, but if I understand you correctly, the main reason to do the clone locally is to save disk space and bandwidth, right? Otherwise it seems to me that it would be simpler to just make two separate clones of the remote repository, assuming that you have a good internet connection and lots
of free disk.


Johannes Schindelin wrote:

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

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!


lilypond-devel mailing list

        Mats Bengtsson
        Signal Processing
        Signals, Sensors and Systems
        Royal Institute of Technology
        SE-100 44  STOCKHOLM
        Phone: (+46) 8 790 8463                         
       Fax:   (+46) 8 790 7260
        Email: address@hidden

reply via email to

[Prev in Thread] Current Thread [Next in Thread]