1. Creating branches starting at a tag
This will create a branch using the 0.29.6 tag as a start:
git branch stable-0.29 0.29.6
2. Switching between branches
git checkout stable-0.30
will make it so the sources in your repo will be the stable-0.30
git checkout master
will return to the master.
3. Add paches already in the Git master branch
git cherry-pick -x f03ffce29627b15a938ba6f0145dc93fb93f6d83
will take the patch f03ffce29627b15a938ba6f0145dc93fb93f6d83 and try to merge it. If it fails, edit the failed file, then do:
git commit -i path/to/file.php
to commit your merge resolved.
4. Pushing the branch to the public Git
Edit your .git/remotes/public, and add a second Push: line like this:
Push: stable-0.30
5. Get a branch from a public repository
Do it like this:
git checkout -b stable-0.30 origin/stable-0.30
Then the following command will show on what branch you will be working with:
git branch
6. Now an example on how to use branching
First clone the dtc git public repo, and get the stable branch:
apt-get install git-core curl
git clone http://git.gplhost.com/dtc.git
cd dtc
git checkout -b stable-0.30 origin/stable-0.30
git checkout master
This did a clone of both the stable and Git version of DTC, then we went back to the master branch.
Now, do all the modifications you want to the master now. When you are happy with the changes, you can type "git commit -a" and this will create a commit that you can later send to the stable if you like. Here is how:
git commit -a
git log | more
then see the sha string ? Something like d3321db468f8e0be3c44c228b26669484fb723b6 is what you are looking for. Then simply do like this to backport your patch:
git checkout stable-0.30
git cherry-pick -x d3321db468f8e0be3c44c228b26669484fb723b6
Then you can build the stable version with the patch included:
dpkg-buildpackage
I know all this sounds complicated, but in fact, it's NOT when you are used to it.
Oh, and if you want to go back to before your patch, simply do:
git reset --hard d3321db468f8e0be3c44c228b26669484fb723b6
Take care, this REMOVES any modifications you did after that hash key.
7. Some more commands to track the branch of somebody
git remote add rudd-o http://git.gplhost.com/users/rudd-o/dtc-xen.git
git fetch rudd-o
git branch -r
git branch --track centos-rpm rudd-o/centos-rpm