Reputation: 4609
I'm developing a software which has mainly two branches right now, master and feature. The problem is I need to work on both of these at the same time.
What I normally do is fire the test suite regression for the feature branch and then continue developing on my master branch.
Since till now we were using CVS, this was easy, different branches resided in different folders and hence had different final build (The final exe).
Now we have switched to GIT and since now both branches reside at the same place (Both build will generate at the same place, with the same name!), how can I continue developing on the master branch so that my feature build is kept intact and the regression doesn't mess up.
Upvotes: 0
Views: 849
Reputation: 6029
I would suggest you just use the tried and tested route from CVS - just clone your git repository twice into separate directories. Then you can work on both branches at the same time and build them separately.
Generally speaking, a single clone works best when switching between branches which are closely related or trivial. If you switch between substantially different branches then the time taken to switch the files and to rebuild starts to become a burden. And the chances are you want to work on branches in parallel and it doesn't make it easy to do that either.
Upvotes: 0
Reputation: 6583
cd /your/git/repository
export GIT_WORK_TREE=/build/directory
git checkout -f $BRANCH_TO_DEPLOY
cd /build/directory
<run build/test/other>
You can run a different build for each branch by separating the build directories.
I am actually using this for a project I work on, where I deploy to production and testing environments from two different branches. It is a good system, however be aware of one thing: depending on your setup, you may need to empty the build directory you are deploying to first, as this checkout method can have issues otherwise.
See this link about git deployment strategies for more details
What is actually happening here?
We are simply checking out a branch to a completely different directory, ie we are separating the repository from the checkout. So we only end up with the files that correspond to the state of the repo after the last commit on $BRANCH_TO_DEPLOY
. We can do this for master branch in one folder, and the feature branch in another, and do different things to those two folders. The last step in my example above is where you would run your test suite.
Upvotes: 1