Multiple Branch Setup
Introduction
When you clone a Git repository it contains all the branches present in the remote repository (the so-called "topic branches"). To switch from one branch to another you just need to git checkout; however this is not convenient, when you need to work on several branches at the same time. For this purpose you can just create as many clones as you need. However, if you want to save some bandwidth/space and only update the object database once for all of these clones, then the following instructions will help you setup multiple clones in a more efficient way.
Multiple working directories
The Git project provides a shell script for working with multiple working directories in the contrib/ directory.
Save it in a folder in your executable PATH and make sure it is executable.
Let's assume that you have created a clone of the TYPO3 repository this way:
cd /usr/local/src/typo3/ git clone git://git.typo3.org/TYPO3v4/Core.git
Your clone will be in /usr/local/src/typo3/Core
git-new-workdir can now be used to create an additional clone that internally uses symbolic links to make work more efficient. By default, it will checkout the "master" branch, but you can supply an optional parameter to checkout another branch. The command:
git-new-workdir Core typo3_4-5-dev TYPO3_4-5
will create a new folder typo3_4-5-dev which contains a link to the same Git clone as "Core" and has the release branch "TYPO3_4-5" already checked out.
The script does not care about submodules, so don't forget to init them:
cd typo3_4-5-dev git submodule update --init
You can now symlink to this folder to use the TYPO3 4.5 source code, while symlink to the "Core" folder to work on the current TYPO3 "master" branch. Repeat as often as necessary with the other branches.
Unfortunately, this being a shell script, Windows users will only be able to use this on Cygwin. If someone knows how to perform a similar setup on Windows, please contribute!
If you also like sparse submodules, you can init the submodules on the Core directory and use a script similar to this named git-typo3:
#!/bin/sh # git-typo3 if git-new-workdir "$1" "$2" $3 && cd "$2"; then for path in `cat .gitmodules |grep '^\[submodule'|cut -d '"' -f 2`; do rmdir "$path" && git-new-workdir "$1/$path" "$path" $3 done git submodule update --init fi
You can then deploy a new branch/tag using:
git-typo3 Core typo3_src-4.5.6 TYPO3_4-5-6
You can also use an git alias like "t3 = typo3 /path/to/Core typo3_src" to keep you from having to type the path to your main clone. Very helpful if you develop your project using git and the typo3_src is a git submodule aswell.