[cmake-developers] git branches and cmake build trees

Alexander Neundorf neundorf at kde.org
Sat Apr 10 16:13:03 EDT 2010


On Friday 09 April 2010, Brad King wrote:
> Michael Wild wrote:
> > A single clone and multiple binary trees in combination with ccache
>
> Since CMake builds in less than 1 minute on my computer I just use
> a single source tree and build tree for all branches.
>
> For bigger projects, you can use local clones as Michael suggested
> first:
>
>   git clone git://cmake.org/cmake.git CMake
>   git clone CMake CMakeMyWork1
>   git clone CMake CMakeMyWork2
>   ...
>
> This will use hard-links to save disk space locally.  However,
> the "origin" of the latter clones will point at the first one.

Ok, I seem to have that mostly working. But I saw some weird behaviour wrt 
branches, and I'm not completely sure everything worked as it should.
This is what I did:

First I created a clone of my CMake clone at gitorious, named CMake-gitorious. 
Then I created a local clone of my CMake-gitorious repository, created a 
branch "IAR-support" and switched to it:

hammer:~/src/CMake$ git clone CMake-gitorious CMake-gitorious-IAR
Initialized empty Git repository in src/CMake/CMake-gitorious-IAR/.git/
hammer:~/src/CMake$ cd CMake-gitorious-IAR/
hammer:~/src/CMake/CMake-gitorious-IAR$ git branch IAR-support
hammer:~/src/CMake/CMake-gitorious-IAR$ git branch
  IAR-support
* master
hammer:~/src/CMake/CMake-gitorious-IAR$ git checkout IAR-support
Switched to branch 'IAR-support'


Then I committed a few changes to this branch and pushed my IAR-support branch 
to gitorious. Everything still good so far I think:


hammer:~/src/CMake/CMake-gitorious-IAR$ git commit -a
...
hammer:~/src/CMake/CMake-gitorious-IAR$ git push origin IAR-support
...
=> Syncing Gitorious... [OK]
To git at gitorious.org:~neundorf/cmake/neundorfs-cmake.git
 * [new branch]      IAR-support -> IAR-support
hammer:~/src/CMake/CMake-gitorious-IAR$              


Now comes the part which I don't understand.
Back in my original CMake-gitorious clone, it doesn't know about 
my "IAR-support" branch, although I thought git would use hardlinks, so the 
changes would be visible there too ?

hammer:~/src/CMake$ cd CMake-gitorious
hammer:~/src/CMake/CMake-gitorious$ git branch
* master


Maybe not, so I tried to see what happens when I pull from gitorious:

hammer:~/src/CMake/CMake-gitorious$ git pull
...
Unpacking objects: 100% (22/22), done.
From git://gitorious.org/~neundorf/cmake/neundorfs-cmake
 * [new branch]      IAR-support -> origin/IAR-support
Already up-to-date.
hammer:~/src/CMake/CMake-gitorious$ git branch
* master


It seems it now received the "IAR-support" branch. But why doesn't "git 
branch" show it ?
I tried to switch to the branch, this work:

hammer:~/src/CMake/CMake-gitorious$ git checkout IAR-support
Branch IAR-support set up to track remote branch IAR-support from origin.
Switched to a new branch 'IAR-support'


Is this normal behaviour ?

Alex



More information about the cmake-developers mailing list