分类:
2009-12-27 14:49:34
This tutorial is a cookbook of recipes getting up and running with Linus's source code management (SCM) software, "git." Its targetted mainly at Linux kernel hackers, though others may find it useful.
|
git requires bootstrapping, since you must have git installed in order to check out git.git (git repository), and linux-2.6.git (kernel repository). You may find that your distribution already provides a usable version of git. If so, try that first.
yum install git-core
Download the latest stable release from: .
tarball build-deps: , libcurl, libcrypto ()
install tarball:
unpack && make && sudo make prefix=/usr/local install
After reading the rest of this document, come back and update your copy of git to the latest: git://git.kernel.org/pub/scm/git/git.git
$ git-clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git linux-2.6
NOTE: The kernel tree is very large. This constitutes downloading several hundred megabytes of data.
$ cd linux-2.6
$ git pull git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
$ git checkout -f
# go to repository
$ cd linux-2.6
# make some modifications
$ vi drivers/net/sk98lin/skdim.c
# NOTE: Run git-add and git-rm if adding or removing files.
# check in all modifications
$ git commit -a
Display changes since last git-update-index:
$ git diff
Display changes since last commit:
$ git diff HEAD
$ git status
$ git log
$ git-whatchanged net/ieee80211/ieee80211_module.c
$ git branch
$ git checkout $branch
$ git checkout -b my-new-branch-name master
$ git branch
(the branch with the asterisk '*' beside it is current)
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 master..HEAD
(this is equivalent to git diff HEAD, when used with HEAD branch)
$ git log master..HEAD
(this is equivalent to git log, when used with HEAD branch)
or rather than full changeset descriptions, obtain a one-line summary of each changes:$ git log master..HEAD | git shortlogLet us suppose that you do work on branch A and branch B, and after work on those two branches is complete, you merge the work into mainline branch M.
$ git checkout M # switch to branch M
$ git pull . A # merge A into M
$ git pull . B # merge B into M
First, make sure that the tools subdirectory of the git-core repository is in your PATH.
The file /path/to/mbox is a Berkeley mbox file, containing one or more patches to be committed to the git repository. The optional file /path/to/signoff.txt is the text file that is appended to each changeset description. For the Linux kernel, this typically includes the
Signed-off-by: Your Name
line that is common to almost all kernel submissions.
git pull only downloads sha1-indexed object data, and the requested remote head. This misses updates to the .git/refs/tags/ and .git/refs/heads/ directories. For tags, run git pull
--tags.