1. Git tree of Linus, aka 'mainline kernel ':
$ Git-clone git: // git .kernel.org/pub/scm/linux/kernel/ git/Torvalds/linux-2.6. Git
Other git trees can be found at [url] http: // git .kernel.org/#/url.pdf. Click here to see the git url.
2. Install git docs
To have the asciidoc, wish command, install the Tcl/TK and asciidoc. Wish commands in the tk-x.xx.xx package.
When compiling git,
$ Sudo make install-Doc
3. Use git
$ Git-config user. Name "Jike song"
$ Git-config user. Email [email] albcamus@gmail.com [/Email]
Note that the configuration information will be written to. Git/config in the current repository directory. If -- Global is added to git-config
Option, the configuration information will be written ~ /. Git config file. Because you may use different identities to participate in different projects, and multiple
Projects are managed using git, so we recommend that you do not use global configuration.
$ Git-Val-l // list git Variables
$ Git-initdb // you do not need to use it unless you create a project. It will create the. Git/directory
// This directory will also be created during Git-clone.
$ Git-clone git: // git .kernel.org/pub/scm/linux/kernel/ git/Torvalds/linux-2.6. Git
$ Linux-2.6 CD
At this point there is a. Git directory under the current directory. We will demonstrate the following in the linux-2.6:
$ Git-pull // update the local git tree. If you clone a Linus tree
// If there are new changes, update these changes to your local tree.
// Similar to CVS update
$ Git-diff // list the differences between your local tree and Linus tree
This is also the way to generate a patch. Note: All Patches generated using Git-diff should be specified-p1 in patch (1 ).
$ Git-apply is equivalent to the patch (1) command, but Git-apply is used to apply patches generated with Git-diff.
-- Check does not really patch the patch, but checks whether the patch can be installed perfectly.
-V verbose
$ Git-Gui // GUI mode, but I think Q git is best to use
$ Git-rev-list <ID> lists revision IDs in reverse order. That is, first column the latest commit ID. You can also specify the number of listed items, for example:
$ Git-rev-list-2 971a71bdc9b42e74a5a8ed0433ac27ae92291024
Add files:
$ Git-add <FILENAME> // similar to CVS add <FILENAME>
$ Git-add-A // all files and subdirectories in the current directory
$ Git-commit // submit. Note that you need to add and then commit. Also, git _ Editor Environment Variables allow you
// Set the editor and use it to edit information during commit.
-S option to add signed-off-by: Jike song for the last line of the commit message <[email] albcamus@gmail.com [/Email]>
$ Git-commit-E-S-
-S adds the signed-off-by line,-E calls Vim to edit the commit message, and-a indicates all.
Delete an object:
$ Git-rm aa. c
$ Git-commit
Restore deleted files: (undo one commit)
$ Git-log // check the git-commit ID after Git-rm
$ Git-revert adb2f08089edac8bf1912a618a74485ab42f2b86 // specify the commit ID that causes the delete operation and undo it.
List the patches corresponding to a commit ID:
$ Git-log-1-P 721151d004dcf01a71b12bb6b893f9160284cf6e
-1 indicates that only one commit is displayed. If you want to display 5,-5. If this parameter is not specified, the GIT log will be displayed from the commit.
There are also simple methods:
$ Git-format-patch-1 721151d004dcf01a71b12bb6b893f9160284cf6e
-- Stdout // print to standard output instead of writing files
Or:
$ Git-show 721151d004dcf01a71b12bb6b893f9160284cf6e // thanks for Xu
Or:
$ Git-diff-tree-P 721151d004dcf01a71b12bb6b893f9160284cf6e
Git-bisect usage
/*{{{*/
$ Git-bisect start
$ Git-bisect bad // This version of kernel is marked as bad
Or targeted:
$ Git-bisect bad v2.6.22-RC1
$ Git-bisect good v2.6.22-RC2
Start the newly compiled kernel. If there is a bug:
$ Git-bisect bad
Goto label; // re-compile and verify.
At some point, there is only one revision to be suspected, and then we can confirm that it has introduced patches.
When bisect ends, it is restored to the master version:
$ Git-bisect Reset
[Note]
Git bisect is a long and painful process. I spent a full day on the Dell optiplex745 (2 GB memory/core2 dual-core 2 GB) machine and located a commit.
[Replay usage]
If you accidentally input Git-bisect bad when entering Git-bisect good, you can do this:
1) git-bisect log | Tee ../git. bisect. Log
2) Modify ../git. bisect. log and delete the last two rows-that is, step 1 of rollback.
3) git-bisect replay ../git. bisect. Log
[Usage of Visualize]
Git-bisect takes a long time because it may need to compile the kernel n times. During this period, you can use:
$ Git-bisect Visualize
To view the revs currently in git K.
FYI: If you prefer Q git like me, you can modify the 'which Git-bisect 'script and replace 'git K' with 'q git '.
/*}}}*/
Git-commit on the git-citool GUI. You can not only submit but also edit the information of the previous commit.
Git-diff usage
List the differences between the tree and the master:
$ Git-diff
List the differences between a tree and a version:
$ Git-diff v2.6.22
List a file, which is different from a previous version:
$ Git diff v2.6.20 init/Main. c
Note that + indicates your own tree and-Indicates 2.6.20 in the result.
List the differences between a file in two tags:
$ Git-diff v2.6.23 v2.6.24-RC1 init/Main. c
Check which patches have been modified for a file:
$ Git-whatchanged-P Security/kconfig // thanks to Herbert Xu
Extract A certain version of kernel from the local git Repository:
$ Git-archive-V v2.6.18 | (CD ../linux-2.6.18/& tar xf -)
-V indicates -- verbose. Note that 'v2. 6.18 'must be one of the tags listed in Git-tag-L.
Or press it into a tarball:
$ Git-archive-V -- format = tar v2.6.24 | Bzip2> ../linux-2.6.24.tar.bz2
Export the current local git repository to another directory (to test the latest Linus tree without messing up the GIT repository)
$ Git-status // fixme: I'm not sure whether to use Git-status or Git-branch.
// Or other commands
$ On Branch master
Nothing to commit (working directory clean)
$ Git-archive-V master | (CD ../linux-2.6-Jan14/& tar xf -)
Your local storage is messy and restored to mailine:
$ Git-reset -- hard // warning: this will cause all your local changes to be lost. Use it with caution!
(Fixme: This method is not correct at all! The commit log is still messy!
Maybe you should use Git-reset -- hard)
$ Git-diff | Tee ../local_against_mainline.diff
$ Git-apply-r <../local_against_mainline.diff
Or:
$ Git-diff | Git-apply-R
You can.
Git analysis Email:
$ Git-mailinfo MSG patch <your-email-file.eml>
Analyze the email, write the commit log to the MSG file, and write the patch to the patch file. Other information is printed to the standard output.
Patch the mail file:
$ Git-am <your-email-file.eml>
Git-send-Email:
For example
$ Git-send-email -- compose -- to [email] jeff@garzik.org [/Email] -- CC [email] davem@davemloft.net [/Email]/
-- CC [email] akpm@linux-foundation.org [/Email] -- CC [email] netdev@vger.kernel.org [/Email]/
-CC [email] linux-kernel@vger.kernel.org [/Email] -- SMTP-server <your-SMTP-Server>/
<Your-patch-name.patch>
Note: My SMTP server does not need to be verified. If you need to verify, use
-- SMTP-user = <your account> -- SMTP-pass = <your passwd>
.
Use Git-tools to process patches in mbox:
$ Git clone git: // git .kernel.org/pub/scm/linux/kernel/ git/Torvalds/Git-tools. Git
Then compile and install the SDK.
It provides tools such as applypatch, cvs2 git, dotest, mailinfo, mailsplit, and stripspace.
Email considerations:
1) xclip can be used to copy patches.
$ Git-format-patch-1 -- stdout <sha-ID> | xclip
Click and paste.
2) carefully confirm your editor
For example, if you use the plug-in of Thunderbird: external editor to specify the vim Editor, make sure that wrap word is not used.
I am not sure whether ~ /. Vimrc sets:
Set textwidth = 0
Set wrapmargin = 0
<EOL> cannot be automatically inserted. However, it is certainly okay to use the R command to read the patch file.