Jeff Garzik's Short git HOWTO

Submitted by Amit Shah
on May 30, 2005 - 5:17am

Jeff Garzik posted a step-by-step guide to using git [story] to manage kernel sources. He states

"One of the things Linus's new 'git' tool allows me to do is make public the 50+ repositories that were previously only available on my local workstation. This should make it a lot easier for developers to see precisely what I have merged, and makes generating follow-up patches a whole lot easier."


From: Jeff Garzik [email blocked]
To: linux-kernel [email blocked]
Subject: [doc][git] playing with git, and netdev/libata-dev trees
Date: Thu, 26 May 2005 01:26:15 -0400

Hopefully, this email can quick-start some people on git.

One of the things Linus's new 'git' tool allows me to do is make public 
the 50+ repositories that were previously only available on my local 
workstation.  This should make it a lot easier for developers to see 
precisely what I have merged, and makes generating follow-up patches a 
whole lot easier.

When I merge a patch for drivers/net/forcedeth.c, I merge it into a 
brand new 'forcedeth' repository, a peer to the 40+ other such 
repository.  Under BitKeeper, I made these repositories available merged 
together into one big "netdev-2.6" repository because it was too time 
consuming to make the individual 50+ trees publicly available.  With 
git, developers have direct access to the individual trees.

I thought I would write up a quick guide describing how to mess around 
with the netdev and libata-dev trees, and with git in general.


1) installing git

git requires bootstrapping, since you must have git installed in order 
to check out git.git (git repo), and linux-2.6.git (kernel repo).  I 
have put together a bootstrap tarball of today's git repository.

Download tarball from:
http://www.kernel.org/pub/linux/kernel/people/jgarzik/git-20050526.tar.bz2

tarball build-deps:  zlib, libcurl

install tarball:  unpack && make && sudo make prefix=/usr/local install

jgarzik helper scripts, not in official git distribution:
http://www.kernel.org/pub/linux/kernel/people/jgarzik/git-switch-tree
http://www.kernel.org/pub/linux/kernel/people/jgarzik/git-new-branch
http://www.kernel.org/pub/linux/kernel/people/jgarzik/git-changes-script

After reading the rest of this document, come back and update your copy 
of git to the latest:
rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/git.git


2) download a linux kernel tree for the very first time

mkdir -p linux-2.6/.git
cd linux-2.6
rsync -a --delete --verbose --stats --progress \ 
rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git/ 
\          <- word-wrapped backslash; sigh
    .git/


3) download latest changes to on-disk local tree

cd linux-2.6
git-pull-script \
rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git


4) check out files from the git repository into the working directory

cd linux-2.6
git-read-tree -m HEAD && git-checkout-cache -q -f -u -a


5) check in your own modifications (e.g. apply a patch)

# go to repo
cd linux-2.6

# make some modifications
patch -sp1 < /tmp/my.patch
diffstat -p1 < /tmp/my.patch

# NOTE: add '--add' and/or '--remove' if files were added or removed
git-update-cache <list of all files changed>

# commit changes
GIT_AUTHOR_NAME="John Doe"		\
    GIT_AUTHOR_EMAIL="jdoe@foo.com"	\
    GIT_COMMITTER_NAME="Jeff Garzik"	\
    GIT_COMMITTER_EMAIL="jgarzik@pobox.com"	\
    git-commit-tree `git-write-tree`	\
    -p $(cat .git/HEAD )			\
    < changelog.txt			\
    > .git/HEAD


6) List all changes in working dir, in diff format.

git-diff-cache -p HEAD


7) List all changesets (i.e. show each cset's description text) in local 
tree that are not present in remote tree.

cd my-kernel-tree-2.6
git-changes-script -L ../linux-2.6 | less


8) List all changesets:

git-whatchanged


9) apply all patches in a Berkeley mbox-format file

First, download and add to your PATH Linus's git tools:
rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/git-tools.git

cd my-kernel-tree-2.6
dotest /path/to/mbox  # yes, Linus has no taste in naming useful scripts


10) don't forget to download tags from time to time.

git-pull-script only downloads sha1-indexed object data, and the 
requested remote head.  This misses updates to the .git/refs/tags/ and 
.git/refs/heads directories.  It is advisable to update your kernel .git 
directories periodically with a full rsync command, to make sure you got 
everything:

cd linux-2.6
rsync -a --delete --verbose --stats --progress \ 
rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git/ 
\          <- word-wrapped backslash; sigh
    .git/


11) [jg-specific] list all branches found in netdev-2.6 or libata-dev trees.

Download
rsync://rsync.kernel.org/pub/scm/linux/kernel/git/jgarzik/netdev-2.6.git
	or
rsync://rsync.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev.git


cd netdev-2.6
ls .git/refs/heads/

{ these are the current netdev-2.6 branches }
> 8139cp       forcedeth    master     qeth           smc91x         we18
> 8139too-iomap  for-linus    natsemi      r8169      smc91x-eeprom  wifi
> airo           hdlc         ns83820      register-netdev  starfire
> atmel          ieee80211    orinoco      remove-drivers   tlan
> chelsio        iff-running  orinoco-hch  sis900           veth
> dm9000         janitor      ppp          skge             viro



12) [jg-specific] make desired branch current in working directory

git-switch-tree $branch


13) [jg-specific] create a new branch, and make it current

git-new-branch $branch


14) [jg-specific] examine which branch is current

ls -l .git/HEAD


15) undo all local modifications (same as checkout):

git-read-tree -m HEAD && git-checkout-cache -q -f -u -a


Related Links:

Cogito

Mark Williamson
on
June 1, 2005 - 5:44am

The Cogito scripts also provide a nice SCM-like frontend to git. It's quite similar in "feel" to using bitkeeper (pull / push, parent repositories, etc.).

plain git

Anonymouss (not verified)
on
June 2, 2005 - 3:56am

i dislike the cogito interface. prefer plain git. :)
also you'll see more toplevel kernel guys using it (as aboves)..

So? 'toplevel guys' are using

Anon (not verified)
on
June 7, 2005 - 3:58am

So? 'toplevel guys' are using it - so it is the best solution or so on?

What I'd like to have is a to

Damjan (not verified)
on
June 14, 2005 - 5:40pm

What I'd like to have is a tool in which I say - get the latest *stable* kernel (2.6.11.11 at this time), also get the out-of-kernel but still stable cifs support, get the latest stable suspend2 patch, get the latest *unstable* (latest latest) madwifi and ipw2x00 drivers, etc.. so that I end with a source tree with my desired components. This way I would test (via using it everyday) the cifs driver before it is included in the stable kernel, but I would avoid the possible major changes in 2.6.12-rc that I can't understand enough to help with testing (like VM or scheduler changes).

Now, I still don't understand GIT (at all), but somehow I feel that it is powerfull enough to do this... and even if it's not today, it could be done in the feature.

What I'm asking here the community or maybe the kernel developers, is to explain if this is possible with GIT today ... or maybe write a very simple script (pull-only, for dummies) to do it all.

What we will gain would be more power to the end users, but also more fine-grained testing of kernel components.

re:What I'd like to have is a to

jonsmirl
on
June 15, 2005 - 2:46pm

You can't build want you want as a general solution. The lastest madwifi driver may use kernel features that are not available in 2.6.11.1. To do this Linux would need a stable binary driver interface, something it does not have and it's not going to get.

What you want is possible some of the time, just not all of the time. You have to look at each set of driver changes and determine if they have started relying on features only available in the new kernel.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.