Re: Updated git HOWTO for kernel hackers

From: Linus Torvalds
Date: Wed Jun 22 2005 - 18:27:59 EST

On Wed, 22 Jun 2005, Jeff Garzik wrote:
> 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://
> \ <- word-wrapped backslash; sigh
> .git/

Gaah. I should do a "git-clone-script" or something that does this, and
then you could just do

git clone rsync:// 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>
> # check in changes
> $ git commit

A few notes on these things:

git-apply --index /tmp/my.patch

will not only apply the patch (unified patches only!), but will do the
index updates for you while it's at it, so if the patch contains new files
(or it deletes files), you don't need to worry about it.

Also, you can do

git commit <list-of-files-to-commit>

as a shorthand for

git-update-cache <list-of-files-to-commit>
git commit

which some people will probably find more natural.

> 6) List all changes in working dir, in diff format.
> $ git-diff-cache -p HEAD

Or, perhaps preferably:

git diff HEAD

since that is shorter ad will also show renames.

> 8) List all changesets:
> $ git-whatchanged

No, if you just want the changesets listed, then

git log

is a lot better, since it shows merges.

"git-whatchanged" is useful if you actually want to see what the commits
_changed_, and then you often want to use the "-p" flag to see it as
patches. Also, it's worth pointing out the fact that you can limit it to
certain subdirectories (or individual files) etc, ie:

git-whatchanged -p drivers/net

since that is often what people want.

But if you just want the log, "git log" is faster and simpler and more

> 16) obtain a diff between current branch, and master branch
> In most trees WITH BRANCHES, .git/refs/heads/master contains the current
> 'vanilla' upstream tree, for easy diffing and merging. (in trees
> without branches, 'master' simply contains your latest changes)
> $ git-diff-tree -p master HEAD

Again, I think is possibly more naturally expressed with "git diff":

git diff master..HEAD

which just says "show the differences from 'master' to 'HEAD'" and will
also show renames etc.

(A plain "git diff" will show just the difference to the index file, in
case you care).

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at