The official git address for Linux kernel is:
Http://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git
You can get kernel's code warehouse from this address.
1. Take the Code warehouse
[Plain]View Plaincopyprint?
- git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
2. View Status:
[Plain]View Plaincopyprint?
- $ git status
- # on Branch Master
- Nothing-to-commit (working directory clean)
3. Update the Local code:
[Plain]View Plaincopyprint?
- $ git pull
- Already up-to-date.
4. Switch to the branch:
[HTML]View Plaincopyprint?
- $ git checkout linux-3.10.y
- Checking out files:100% (25952/25952), done.
- Switched to branch ' LINUX-3.10.Y '
5. View the branch information:
[Plain]View Plaincopyprint?
- $ git Branch
- * LINUX-3.10.Y
- Master
[Plain]View Plaincopyprint?
- $ git branch-a
- * LINUX-3.10.Y
- Master
- Remotes/origin/head-Origin/master
- Remotes/origin/linux-2.6.11.y
- Remotes/origin/linux-2.6.12.y
- Remotes/origin/linux-2.6.13.y
- Remotes/origin/linux-2.6.14.y
- Remotes/origin/linux-2.6.15.y
- Remotes/origin/linux-2.6.16.y
- Remotes/origin/linux-2.6.17.y
- Remotes/origin/linux-2.6.18.y
- Remotes/origin/linux-2.6.19.y
- Remotes/origin/linux-2.6.20.y
- Remotes/origin/linux-2.6.21.y
- Remotes/origin/linux-2.6.22.y
- Remotes/origin/linux-2.6.23.y
- Remotes/origin/linux-2.6.24.y
- Remotes/origin/linux-2.6.25.y
- Remotes/origin/linux-2.6.26.y
- Remotes/origin/linux-2.6.27.y
- Remotes/origin/linux-2.6.28.y
- Remotes/origin/linux-2.6.29.y
- Remotes/origin/linux-2.6.30.y
- Remotes/origin/linux-2.6.31.y
- Remotes/origin/linux-2.6.32.y
- Remotes/origin/linux-2.6.33.y
- Remotes/origin/linux-2.6.34.y
- Remotes/origin/linux-2.6.35.y
- Remotes/origin/linux-2.6.36.y
- Remotes/origin/linux-2.6.37.y
- Remotes/origin/linux-2.6.38.y
- Remotes/origin/linux-2.6.39.y
- Remotes/origin/linux-3.0.y
- Remotes/origin/linux-3.1.y
- Remotes/origin/linux-3.10.y
- Remotes/origin/linux-3.11.y
- Remotes/origin/linux-3.12.y
- Remotes/origin/linux-3.13.y
- Remotes/origin/linux-3.14.y
- Remotes/origin/linux-3.2.y
- Remotes/origin/linux-3.3.y
- Remotes/origin/linux-3.4.y
- Remotes/origin/linux-3.5.y
- Remotes/origin/linux-3.6.y
- Remotes/origin/linux-3.7.y
- Remotes/origin/linux-3.8.y
- Remotes/origin/linux-3.9.y
- Remotes/origin/master
6. Create a new branch:
[Plain]View Plaincopyprint?
- $ git checkout-b linux-3.10-charles
- Switched to a new branch ' Linux-3.10-charles '
[HTML]View Plaincopyprint?
- $ git Branch
- * Linux-3.10-charles
- Linux-3.10.y
- Master
7. Modify the file init/main.c, add a line of comments, and then execute
[HTML]View Plaincopyprint?
- git Add.
[HTML]View Plaincopyprint?
- $ git status
- # on Branch Linux-3.10-charles
- # Changes to be committed:
- # (use "Git reset HEAD <file; ..." to Unstage)
- #
- # MODIFIED:INIT/MAIN.C
- #
[HTML]View Plaincopyprint?
- E$&NBSP;GIT&NBSP;ADD&NBSP;-I&NBSP;&NBSP;
- staged unstaged path
- 1: +2/-0 nothing init/main.c
-
- ** * commands ***
- 1: [s]tatus 2: [u]pdate 3: [r]evert 4: [a]dd untracked
- &NBSP;&NBSP;5:&NBSP;[P]ATCH&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;6: [d]iff 7: [q]uit 8: [h]elp
- What now >
If you choose the Revert command, the equivalent of undo "git Add.":
[HTML]View Plaincopyprint?
- What's now> R
- Staged unstaged path
- 1: +2/-0 Nothing [i]nit/main.c
- Revert>>
- Reverted one path
- Commands * * *
- 1: [S]tatus 2: [u]pdate 3: [R]evert 4: [A]dd untracked
- 5: [P]atch 6: [D]iff 7: [q]uit 8: [H]elp
- What's now> Q
At this point, git status is executed:
[HTML]View Plaincopyprint?
- $ git status
- # on Branch Linux-3.10-charles
- # changes not staged for commit:
- # (use "git add <file; ..." to update What'll be committed)
- # (use "Git checkout- <file ..." to discard changes in working directory)
- #
- # MODIFIED:INIT/MAIN.C
- #
- No changes added to commit (use "git add" and/or "Git Commit-a")
8. Submit Changes:
[Plain]View Plaincopyprint?
- $ git commit-a-M "This was just for testing git"
- [Linux-3.10-charles 9eabb78] This is just for testing git
- 1 file changed, 1 insertion (+), 1 deletion (-)
9. View the change history (git log):
[Plain]View Plaincopyprint?
- Commit 9EABB788B5C33EFED589B1263AEDD69B97E592AC
- Author:taotao Ding <[email protected]>
- Date:wed 7 03:36:55 2014 +0900
- This is just for testing git
- Commit 5D897EEDC505BB8AF1F4865AE381EADBFD3BC8C1
- Author:greg Kroah-hartman <[email protected]>
- Date:tue May 6 07:56:24 2014-0700
- Linux 3.10.39
- Commit 6B32172A1D3CFFA74067CED96612BD13658D4FCF
- Author:felipe Balbi <[email protected]>
- Date:tue Feb 25 10:58:43 2014-0600
- Usb:musb:avoid NULL Pointer dereference
As you can see, the changes have been recorded.
[Plain]View Plaincopyprint?
- Git log-p
- Commit 9EABB788B5C33EFED589B1263AEDD69B97E592AC
- Author:taotao Ding <[email protected]>
- Date:wed 7 03:36:55 2014 +0900
- This is just for testing git
- Diff--git A/init/main.c B/init/main.c
- Index E83AC04: Febc1e9 100644
- ---a/init/main.c
- + + B/INIT/MAIN.C
- @@ -10,7 +10,7 @@
- */
- #define DEBUG/* Enable Initcall_debug */
- -
- +/* This was a test line for git */
- #include <linux/types.h>
- #include <linux/module.h>
- #include <linux/proc_fs.h>
10: View a file's most recent modification record:
[HTML]View Plaincopyprint?
- $ git log master: HEAD INIT/MAIN.C
- Commit 9EABB788B5C33EFED589B1263AEDD69B97E592AC
- Author:taotao Ding <[email protected]>
- Date:wed 7 03:36:55 2014 +0900
- This is just for testing git
- Commit B7A52F5111BC53FFBFFF96330621CBDE80DF6BA4
- Author:theodore Ts ' O <[email protected]>
- Date:tue SEP 10 10:52:35 2013-0400
- Random:run Random_int_secret_init () run after all Late_initcalls
- Commit 47D06E532E95B71C0DB3839EBDEF3FE8812FCA2C upstream.
- The some platforms (e.g., ARM) initializes their clocks as
- Late_initcalls for some unknown reason. So make sure
- Random_int_secret_init () is a run after any of the late_initcalls is
- Run.
- Signed-off-by: "Theodore Ts ' O" <[email protected]>
- Signed-off-by:greg Kroah-hartman <[email protected]>
11: Compare the differences between the two branches:
[HTML]View Plaincopyprint?
- $ git log linux-3.10.y. Linux-3.10-charles
- Commit 9EABB788B5C33EFED589B1263AEDD69B97E592AC
- Author:taotao Ding <[email protected]>
- Date:wed 7 03:36:55 2014 +0900
- This is just for testing git
The current branch can also be written as HEAD, so:
[Plain]View Plaincopyprint?
- $ git log linux-3.10.y. HEAD
- Commit 9EABB788B5C33EFED589B1263AEDD69B97E592AC
- Author:taotao Ding <[email protected]>
- Date:wed 7 03:36:55 2014 +0900
- This is just for testing git
Reference
http://www.opensourceforu.com/2011/05/linux-kernel-development-using-git/
P.S.
Ways to configure username and User.email:
git config user.email "username"
git config user.email "[email protected]"
These two commands change the. Git/config configuration file (local)
git config--global user.email "username"
git config--global user.email "[Email protected]"
git config--global core.editor "vim"
Then change the global git configuration file (~/.gitconfig)
Use GIT to get code for Linux kernel and view, track history