Git tips and trick that are hard to find in the tutorials and man
This page attempts to capture some of the more useful features of git
that are just about impossible to figure out without someone's help.
Although I'm a kernel developer I've avoided git and bitkeeper before
it like the plague. This year I was forced to take the
plunge and started by reading the man pages the tutorials all over the
network. I found them un-helpful for most practical
applications and uses of git.
I found myself setting up multiple git clone trees one for each kernel
project I was interested, the Linus tree, the next tree, the rt tree
and was diffing files between each. This is not effective or
helpful, and as typical in software if something seems like it should
be easier, it usually is and you simply don't know the trick yet.
Enter git with multiple remotes. Learning about these made me
feel sorry (only a
little) for all the git bashing I've done.
I'm currently working on a project where we have an internal tree, and
have to track an upstream external tree keeping up with the significant
the external tree. Git makes it easy to re-base or merge our
After you have set up your baseline upstream repo you can use
git-remote add <name you pick>
<remote repo git URL>:
git-remote add realtime git://git.kernel.org/pub/scm/linux/kernel/git/tglx/linux-2.6-hrt.git
Once you have the remotes added you now need to create local branches
associated with each so you can easily work between each one and your
own local work. Use git-branch
-b <name you pick> <name
chosen in git-add call/remote-branch-you-care-about>.
Note git-checkout works the same way only it will create
the branch and check it out in one command.
git-remote add internal-project email@example.com:/internal-project/kernel
git-branch rt realtime/master
At this point you have set up your remotes and now you can work away on
the internal branch while the remotes continue on there happy
way. At some point its time to re-sync with upstream an you need
to "fetch", don't use pull at this point as it does too many things and
could mess you up if your current branch is not what you thought at the
time you issue the "pull", git-fetch
<branch name you
git-checkout -b rt realtime/master
git-branch internal internal-project/xxx
git-checkout -b internal internal-project/xxx
This command will not change your working directory or your private
working branches but will update the backing stores for the remote
tracking branches. Now you can merge or rebase your work between
these branches or cherry pick (look it up, see "git-cherry-pick")
patches from rt and internal to merge into the internal branch
which you will later "push" so other folks can work with it.
Ok, I know this is is a lame tutorial, but its not supposed to be a
tutorial its just a set of tips. You should look closely at the
man pages for the following commands:
git-branch, git-checkout, git-remote, git-merge, git-rebase, git-push
My typical git commands are:
It would do you good to study the documentation around this set of