Use GIT to get code for Linux kernel and view, track history

Source: Internet
Author: User
Tags git clone

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?
    1. git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git


2. View Status:

[Plain]View Plaincopyprint?
    1. $ git status
    2. # on Branch Master
    3. Nothing-to-commit (working directory clean)


3. Update the Local code:

[Plain]View Plaincopyprint?
    1. $ git pull
    2. Already up-to-date.


4. Switch to the branch:

[HTML]View Plaincopyprint?
    1. $ git checkout linux-3.10.y
    2. Checking out files:100% (25952/25952), done.
    3. Switched to branch ' LINUX-3.10.Y '

5. View the branch information:

[Plain]View Plaincopyprint?
    1. $ git Branch
    2. * LINUX-3.10.Y
    3. Master
[Plain]View Plaincopyprint?
  1. $ git branch-a
  2. * LINUX-3.10.Y
  3. Master
  4. Remotes/origin/head-Origin/master
  5. Remotes/origin/linux-2.6.11.y
  6. Remotes/origin/linux-2.6.12.y
  7. Remotes/origin/linux-2.6.13.y
  8. Remotes/origin/linux-2.6.14.y
  9. Remotes/origin/linux-2.6.15.y
  10. Remotes/origin/linux-2.6.16.y
  11. Remotes/origin/linux-2.6.17.y
  12. Remotes/origin/linux-2.6.18.y
  13. Remotes/origin/linux-2.6.19.y
  14. Remotes/origin/linux-2.6.20.y
  15. Remotes/origin/linux-2.6.21.y
  16. Remotes/origin/linux-2.6.22.y
  17. Remotes/origin/linux-2.6.23.y
  18. Remotes/origin/linux-2.6.24.y
  19. Remotes/origin/linux-2.6.25.y
  20. Remotes/origin/linux-2.6.26.y
  21. Remotes/origin/linux-2.6.27.y
  22. Remotes/origin/linux-2.6.28.y
  23. Remotes/origin/linux-2.6.29.y
  24. Remotes/origin/linux-2.6.30.y
  25. Remotes/origin/linux-2.6.31.y
  26. Remotes/origin/linux-2.6.32.y
  27. Remotes/origin/linux-2.6.33.y
  28. Remotes/origin/linux-2.6.34.y
  29. Remotes/origin/linux-2.6.35.y
  30. Remotes/origin/linux-2.6.36.y
  31. Remotes/origin/linux-2.6.37.y
  32. Remotes/origin/linux-2.6.38.y
  33. Remotes/origin/linux-2.6.39.y
  34. Remotes/origin/linux-3.0.y
  35. Remotes/origin/linux-3.1.y
  36. Remotes/origin/linux-3.10.y
  37. Remotes/origin/linux-3.11.y
  38. Remotes/origin/linux-3.12.y
  39. Remotes/origin/linux-3.13.y
  40. Remotes/origin/linux-3.14.y
  41. Remotes/origin/linux-3.2.y
  42. Remotes/origin/linux-3.3.y
  43. Remotes/origin/linux-3.4.y
  44. Remotes/origin/linux-3.5.y
  45. Remotes/origin/linux-3.6.y
  46. Remotes/origin/linux-3.7.y
  47. Remotes/origin/linux-3.8.y
  48. Remotes/origin/linux-3.9.y
  49. Remotes/origin/master


6. Create a new branch:

[Plain]View Plaincopyprint?
    1. $ git checkout-b linux-3.10-charles
    2. Switched to a new branch ' Linux-3.10-charles '
[HTML]View Plaincopyprint?
    1. $ git Branch
    2. * Linux-3.10-charles
    3. Linux-3.10.y
    4. Master

7. Modify the file init/main.c, add a line of comments, and then execute

[HTML]View Plaincopyprint?
    1. git Add.
[HTML]View Plaincopyprint?
    1. $ git status
    2. # on Branch Linux-3.10-charles
    3. # Changes to be committed:
    4. # (use "Git reset HEAD <file; ..." to Unstage)
    5. #
    6. # MODIFIED:INIT/MAIN.C
    7. #

[HTML]View Plaincopyprint?
    1. E$&NBSP;GIT&NBSP;ADD&NBSP;-I&NBSP;&NBSP;
    2.             staged     unstaged path   
    3.   1:        +2/-0       nothing init/main.c  
    4.   
    5. ** * commands ***  
    6.   1: [s]tatus     2:  [u]pdate     3: [r]evert     4: [a]dd  untracked  
    7. &NBSP;&NBSP;5:&NBSP;[P]ATCH&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;6:  [d]iff   7: [q]uit   8: [h]elp  
    8. What now >   


If you choose the Revert command, the equivalent of undo "git Add.":

[HTML]View Plaincopyprint?
  1. What's now> R
  2. Staged unstaged path
  3. 1: +2/-0 Nothing [i]nit/main.c
  4. Revert>>
  5. Reverted one path
  6. Commands * * *
  7. 1: [S]tatus 2: [u]pdate 3: [R]evert 4: [A]dd untracked
  8. 5: [P]atch 6: [D]iff 7: [q]uit 8: [H]elp
  9. What's now> Q

At this point, git status is executed:

[HTML]View Plaincopyprint?
  1. $ git status
  2. # on Branch Linux-3.10-charles
  3. # changes not staged for commit:
  4. # (use "git add <file; ..." to update What'll be committed)
  5. # (use "Git checkout- <file ..." to discard changes in working directory)
  6. #
  7. # MODIFIED:INIT/MAIN.C
  8. #
  9. No changes added to commit (use "git add" and/or "Git Commit-a")


8. Submit Changes:

[Plain]View Plaincopyprint?
    1. $ git commit-a-M "This was just for testing git"
    2. [Linux-3.10-charles 9eabb78] This is just for testing git
    3. 1 file changed, 1 insertion (+), 1 deletion (-)

9. View the change history (git log):

[Plain]View Plaincopyprint?
  1. Commit 9EABB788B5C33EFED589B1263AEDD69B97E592AC
  2. Author:taotao Ding <[email protected]>
  3. Date:wed 7 03:36:55 2014 +0900
  4. This is just for testing git
  5. Commit 5D897EEDC505BB8AF1F4865AE381EADBFD3BC8C1
  6. Author:greg Kroah-hartman <[email protected]>
  7. Date:tue May 6 07:56:24 2014-0700
  8. Linux 3.10.39
  9. Commit 6B32172A1D3CFFA74067CED96612BD13658D4FCF
  10. Author:felipe Balbi <[email protected]>
  11. Date:tue Feb 25 10:58:43 2014-0600
  12. Usb:musb:avoid NULL Pointer dereference

As you can see, the changes have been recorded.

[Plain]View Plaincopyprint?
  1. Git log-p
  2. Commit 9EABB788B5C33EFED589B1263AEDD69B97E592AC
  3. Author:taotao Ding <[email protected]>
  4. Date:wed 7 03:36:55 2014 +0900
  5. This is just for testing git
  6. Diff--git A/init/main.c B/init/main.c
  7. Index E83AC04: Febc1e9 100644
  8. ---a/init/main.c
  9. + + B/INIT/MAIN.C
  10. @@ -10,7 +10,7 @@
  11. */
  12. #define DEBUG/* Enable Initcall_debug */
  13. -
  14. +/* This was a test line for git */
  15. #include <linux/types.h>
  16. #include <linux/module.h>
  17. #include <linux/proc_fs.h>


10: View a file's most recent modification record:

[HTML]View Plaincopyprint?
  1. $ git log master: HEAD INIT/MAIN.C
  2. Commit 9EABB788B5C33EFED589B1263AEDD69B97E592AC
  3. Author:taotao Ding <[email protected]>
  4. Date:wed 7 03:36:55 2014 +0900
  5. This is just for testing git
  6. Commit B7A52F5111BC53FFBFFF96330621CBDE80DF6BA4
  7. Author:theodore Ts ' O <[email protected]>
  8. Date:tue SEP 10 10:52:35 2013-0400
  9. Random:run Random_int_secret_init () run after all Late_initcalls
  10. Commit 47D06E532E95B71C0DB3839EBDEF3FE8812FCA2C upstream.
  11. The some platforms (e.g., ARM) initializes their clocks as
  12. Late_initcalls for some unknown reason. So make sure
  13. Random_int_secret_init () is a run after any of the late_initcalls is
  14. Run.
  15. Signed-off-by: "Theodore Ts ' O" <[email protected]>
  16. Signed-off-by:greg Kroah-hartman <[email protected]>


11: Compare the differences between the two branches:

[HTML]View Plaincopyprint?
    1. $ git log linux-3.10.y. Linux-3.10-charles
    2. Commit 9EABB788B5C33EFED589B1263AEDD69B97E592AC
    3. Author:taotao Ding <[email protected]>
    4. Date:wed 7 03:36:55 2014 +0900
    5. This is just for testing git


The current branch can also be written as HEAD, so:

[Plain]View Plaincopyprint?
    1. $ git log linux-3.10.y. HEAD
    2. Commit 9EABB788B5C33EFED589B1263AEDD69B97E592AC
    3. Author:taotao Ding <[email protected]>
    4. Date:wed 7 03:36:55 2014 +0900
    5. 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.