/ Published in: Groovy
Posted it here because his website disappeared.
Expand |
Embed | Plain Text
Kernel Hackers' Guide to git Menu: * Serial ATA * IPv6 * DNS * Current projects 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. Table of Contents * Getting Started o Installing git o First kernel tree download * Basic tasks o Download remote tree updates o Undo all working dir modifications o Undo recent commits o Check in changes o Generate diff of working dir changes o Generate summary of working dir changes o List all changeset descriptions o List all changeset descriptions belonging to a specific file * Branches o List all branches o Create new branch o List current branch o Diff against master branch o List changes present only on local branch o Merge changes from one branch into another * Misc. debris o Check out an older kernel version o Apply mailbox full of patches o Download tags periodically o Create a tag * Further reading Getting Started Installing git git requires bootstrapping, since you must have git installed in order to check out git.git yum install git-core http://www.kernel.org/pub/software/scm/git/ tarball build-deps: zlib, libcurl, libcrypto (openssl) install tarball: unpack && make prefix=/usr/local && 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 Download a linux kernel tree for the very first time $ 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 just over 300 megabytes of Basic Tasks Update local kernel tree to latest 2.6.x upstream ("fast-forward merge") $ cd linux-2.6 $ git pull git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git or more simply, to pull from the location from which you cloned: $ cd linux-2.6 $ git pull to pull from the origin repository from which you originally cloned the tree. Undo all local modifications: $ 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 Undo recent commits: Sometimes you have made a few commits, or just pulled a change, and simply want those commits to go away. $ cd my-kernel-tree-2.6 $ git reset HEAD~2 # make last 2 commits disappear containing the commits you just eliminated. additional commit. Display changes since last 'git add' or 'git rm': $ git diff Display changes since last commit: $ git diff HEAD Obtain summary of all changes in working dir $ git status List all changeset descriptions $ git log List all changesets belonging to a specific file $ git log net/ieee80211/ieee80211_module.c Branches List all branches $ git branch Make desired branch current in working directory $ git checkout $branch Create a new branch, and make it current $ git checkout -b my-new-branch-name master Examine which branch is current $ git status Obtain a diff between current branch, and master branch your latest changes) $ git diff master..HEAD Obtain a list of changes between current branch, and master branch $ git log master..HEAD or rather than full changeset descriptions, obtain a one-line summary of each changes: $ git shortlog master..HEAD Merge changes from one branch into another Let 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 merge A # merge A into M $ git merge B # merge B into M Misc. Debris Optimize your repository over a long period of time, it can be useful to perform further optimizations, including packing all git objects into single "packfile" for fast retrieval and less wasted disk space. $ cd my-kernel-tree-2.6 $ git gc will optimize your repository. You don't need to run this frequently รข git is quite fast even without it. See the 'git gc' man page for more details. Check out an older kernel version $ cd my-kernel-tree-2.6 $ git checkout -b tmp v2.6.22 This creates a temporary branch 'tmp', with the contents of kernel version 2.6.22. Apply all patches in a Berkeley mbox-format file First, make sure that the tools subdirectory of the git-core repository is in your PATH. $ cd my-kernel-tree-2.6 $ git am --utf8 --signoff /path/to/mbox The file /path/to/mbox is a Berkeley mbox file, containing one or more patches to be committed to the git repository. The --signoff option indicates that 'git am' should append the Signed-off-by: Your Name <[email protected]> line that is common to almost all kernel submissions. The name and email address are taken from the GIT_COMMITTER_NAME and GIT_COMMITTER_EMAIL environment variables (I recommend setting these in your .bash_profile or similar file). Don't forget to download tags from time to time. --tags $URL. Tag a particular commit. For your own repositories, you may wish to give interesting or significant commits a name, etc. $ cd my-kernel-tree-2.6 $ git tag my-tag tagging, including GPG-signing, so read the man page for more details. Further reading Another good introduction is the official git tutorial, followed by the more in-depth git man page documentation.
You need to login to post a comment.
