views:

213

answers:

3

Is it possible to take a repository (such as CakePHP1.x @ http://github.com/cakephp/cakephp1x) and checkout the master plus branches into sub-folders?

For example, my desired folder structure would be like this:

cakephp1.x

|------ 1.2

|------ 1.3

|------ master

I know you can use git checkout -t origin/branch to switch between branches from a cloned repository, but I was wondering if there was a way to do the above without having to clone the repository and rename repeatedly.

+4  A: 

You could do something like this:

mkdir cakephp
cd cakephp
git clone git://github.com/cakephp/cakephp1x.git master
cd master
git checkout -t origin/1.2
git checkout -t origin/1.3
cd ..
git clone master 1.2
git clone master 1.3
cd 1.2
git checkout -t origin/1.2

The two local git clone operations will be very quick because they will use hard links to share most of the repository data.

Greg Hewgill
Thanks, this is exactly what I wanted to achieve. I was wondering though - if I do a 'git pull' on the master, this works great - how would I pull down updates on the 1.2 / 1.3 branches?
atomicguava
After doing a `git pull` on the master, do a `git pull` on the 1.2/1.3 branches, which will pull from master (due to *their* tracking branches). Or, you could add github as a new remote to the branch repositories and pull directly. Git is like Perl - there's more than one way to do it!
Greg Hewgill
Thanks very much Greg!
atomicguava
A: 

cloning the repository is not a very big deal. If it happends on a local filesystem most of the repository contents is cloned via hard links.

Antony Hatchkins
A: 

Somehow related to this ?!

Stefan Näwe