Linux kernel  的官方 GIT地址是:

http://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git

可以从这个地址拿到 kernel 的 代码仓库。

1. 拿代码仓库

git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git  

2. 查看状态:

3. 更新本地的代码:

$ git pull
Already up-to-date.

4. 切换到分支:

$ git checkout linux-3.10.y
Checking out files: % (/), done.
Switched to branch 'linux-3.10.y'

5. 查看分支信息:

$ git branch
* linux-3.10.y
master

6. 创建一个新分支:

$ git checkout -b linux-3.10-charles
Switched to a new branch 'linux-3.10-charles'
$ git branch
* linux-3.10-charles
linux-3.10.y
master

7. 修改文件 init/main.c, 加入一行注释,然后 执行

git add .  
$ git status
# On branch linux-3.10-charles
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: init/main.c
#

如果选择  revert 命令,相当于 undo  "git add .":

What now> r
staged unstaged path
: +/- nothing [i]nit/main.c
Revert>>
reverted one path *** Commands ***
: [s]tatus : [u]pdate : [r]evert : [a]dd untracked
: [p]atch : [d]iff : [q]uit : [h]elp
What now> q

这个时候再执行 git status:

$ git status
# On branch linux-3.10-charles
# Changes not staged for commit:
# (use "git add <file>..." to update what will 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. 提交修改:

$ git commit -a -m "This is just for testing git"
[linux-3.10-charles 9eabb78] This is just for testing git
file changed, insertion(+), deletion(-)

9. 查看修改记录(git log):

commit 9eabb788b5c33efed589b1263aedd69b97e592ac
Author: Taotao Ding <htdkd@hotmail.com>
Date: Wed May :: + This is just for testing git commit 5d897eedc505bb8af1f4865ae381eadbfd3bc8c1
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date: Tue May :: - Linux 3.10. commit 6b32172a1d3cffa74067ced96612bd13658d4fcf
Author: Felipe Balbi <balbi@ti.com>
Date: Tue Feb :: - usb: musb: avoid NULL pointer dereference
  

可以看到,修改已经被记录起来了。

git log  -p
commit 9eabb788b5c33efed589b1263aedd69b97e592ac
Author: Taotao Ding <htdkd@hotmail.com>
Date: Wed May :: + This is just for testing git diff --git a/init/main.c b/init/main.c
index e83ac04..febc1e9
--- a/init/main.c
+++ b/init/main.c
@@ -, +, @@
*/ #define DEBUG /* Enable initcall_debug */
-
+/* This is a test line for git */
#include <linux/types.h>
#include <linux/module.h>
#include <linux/proc_fs.h>

10: 查看一个文件最近的修改记录:

$ git log master..HEAD init/main.c
commit 9eabb788b5c33efed589b1263aedd69b97e592ac
Author: Taotao Ding <htdkd@hotmail.com>
Date: Wed May :: + This is just for testing git commit b7a52f5111bc53ffbfff96330621cbde80df6ba4
Author: Theodore Ts'o <tytso@mit.edu>
Date: Tue Sep :: - 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 run after all of the late_initcalls are
run. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

11: 比较两个分支的差异:

$ git log linux-3.10.y..linux-3.10-charles
commit 9eabb788b5c33efed589b1263aedd69b97e592ac
Author: Taotao Ding <htdkd@hotmail.com>
Date: Wed May :: + This is just for testing git

当前分支也可写成  HEAD,所以:

$ git log linux-3.10.y..HEAD
commit 9eabb788b5c33efed589b1263aedd69b97e592ac
Author: Taotao Ding <htdkd@hotmail.com>
Date: Wed May :: + This is just for testing git

reference:

http://www.opensourceforu.com/2011/05/linux-kernel-development-using-git/

P.S.

配置 username  和 user.email 的方法:

git config    user.email "username"

git config   user.email "email@server"

这两个命令改变 .git/config 配置文件 (local)

git config  --global   user.email "username"

git config   --global user.email "email@server"

git config --global core.editor "vim"
则改变全局的 git 配置文件  (~/.gitconfig)

使用 GIT 获得Linux Kernel的代码并查看,追踪历史记录的更多相关文章

  1. ubuntu 下 使用 Git 维护 linux kernel版本

    学习linux内核一段时间,意识到内核的版本需要严格控制.利用Git工具可以很轻松的完成不同开发人员不同模块之间的代码融合与版本控制 . 1. 首先,安装Git .可以参考廖雪峰的博客  https: ...

  2. 拥抱开源,怎样关注Linux Kernel 邮件列表?

    现在开源如此火爆.以至于张口闭口不提到都仿佛不是搞IT 的.那么怎样拥抱开源?本文适合刚開始学习的人,如有大神至此,goto exit ! 一.怎样增加开源 以Linux 为例,这么一个成功的开源项目 ...

  3. Linux Kernel代码艺术——系统调用宏定义

    我们习惯在SI(Source Insight)中阅读Linux内核,SI会建立符号表数据库,能非常方便地跳转到变量.宏.函数等的定义处.但在处理系统调用的函数时,却会遇到一些麻烦:我们知道系统调用函数 ...

  4. Linux Kernel 代码艺术——编译时断言

    本系列文章主要写我在阅读Linux内核过程中,关注的比较难以理解但又设计巧妙的代码片段(不关注OS的各个模块的设计思想,此部分我准备写在“深入理解Linux Kernel” 系列文章中),一来通过内核 ...

  5. arm linux kernel 从入口到start_kernel 的代码分析

    参考资料: <ARM体系结构与编程> <嵌入式Linux应用开发完全手册> Linux_Memory_Address_Mapping http://www.chinaunix. ...

  6. Linux Kernel系列 - 黄牛X内核代码凝视

    Hanks.Wang - 专注于操作系统与移动安全研究.Linux-Kernel/SELinux/SEAndroid/TrustZone/Encription/MDM    Mail - byhank ...

  7. Linux kernel Vhost-net 和 Virtio-net代码详解

    场景 Host上运行qemu kvm虚拟机,其中虚拟机的网卡类型为virtio-net,而Host上virtio-net backend使用vhost-net 数据包进入虚拟机代码分析 首先看vhos ...

  8. Linux kernel的中断子系统之(七):GIC代码分析

    返回目录:<ARM-Linux中断系统>. 总结: 原文地址:<linux kernel的中断子系统之(七):GIC代码分析> 参考代码:http://elixir.free- ...

  9. Linux Kernel 代码艺术——编译时断言【转】

    转自:http://www.cnblogs.com/hazir/p/static_assert_macro.html 本系列文章主要写我在阅读Linux内核过程中,关注的比较难以理解但又设计巧妙的代码 ...

随机推荐

  1. 短小强悍的JavaScript异步调用库

    对于博文 20行完成一个JavaScript模板引擎 的备受好评我感到很惊讶,并决定用此文章介绍使用我经常使用的另一个小巧实用的工具.我们知道,在浏览器中的 JavaScript 绝大部分的操作都是异 ...

  2. java 进制转化

    public static void toBinary(int num){ trans(num,1,1); } public static void toHex(int num){ trans(num ...

  3. iOS优化内存方法推荐

    1. 用ARC管理内存 ARC(Automatic ReferenceCounting, 自动引用计数)和iOS5一起发布,它避免了最常见的也就是经常是由于我们忘记释放内存所造成的内存泄露.它自动为你 ...

  4. 那些我用过的Android开源项目

    1.RefreshActionItem 基于ActionBarSherlock库的一个扩展,在标题栏右边显示多种刷新效果的UI按钮. 项目主页: https://github.com/ManuelPe ...

  5. S.O.L.I.D五大原则- 深入了解javascript

    /* S.O.L.I.D五大原则 1. 单一原则 2. 开闭原则 3. 里氏替换原则 4. 接口分离原则 5. 依赖反转原则 */ /*单一原则:类发生更改的原因只有一个 如何知道一个对象的多个行为构 ...

  6. STS中取消show in Breadcrumb方法

    前言:STS是Spring产品下的一个开发工具,它和eclipse很像,只不过对Spring有更好的兼容.Show in Breadcrumb是快速导航条,可以清晰的看到我们当前的类,属性或方法的导航 ...

  7. 20160730noip模拟赛zld

    codeforces394E 如果没有在凸多边形内一点的限制,答案肯定是 如果不在凸多边形内,那么目标点肯定在凸多边形边上,我们枚举每条边,在每条边上求出距离平方和最小的点,在这些点中求出最小的 我们 ...

  8. Open Phone, SMS, Email, Skype and Browser apps of Android in Unity3d

    最近项目需要使用Android的一些基本功能,写插件各种悲剧,google了一下,如获至宝.Nice ! string url = String.Format("tel:{0}", ...

  9. Unity3D脚本中文系列教程(三)

    http://dong2008hong.blog.163.com/blog/static/4696882720140302323886/ Unity3D脚本中文系列教程(二) 示,属性不被序列化或显示 ...

  10. D&F学数据结构系列——红黑树

    红黑树 定义:一棵二叉查找树如果满足下面的红黑性质,则为一棵红黑树: 1)每个结点不是红的就是黑的 2)根结点是黑的 3)每个叶结点是黑的 4)如果一个结点是红的,它的两个儿子都是黑的(即不可能有两个 ...