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. orcale 修改字段属性

    有些时候,因为没能预料到一些情况的变化,需要修改字段的类型.如果是varchar型,直接增加长度是可以的,但是如果需要修改成其他类型就不能这么做了. 思路:1.增加一个临时列,把需要修改的那个字段的数 ...

  2. 使用ASP.NET注册工具aspnet_regiis.exe注册IIS

    该工具的名称为aspnet_regiis.exe,在32位机上,该工具存在于C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727,在64位机中“Framework ...

  3. Ubuntu重启网络/etc/init.d/networking restart报错

    Linux版本:Ubuntu 12.04 配置网口后重启网络,提示/etc/init.d/networking restart is deprecated. $ sudo /etc/init.d/ne ...

  4. Makedown常用符号整理

    整理自:http://www.jianshu.com/p/1e402922ee32 不过这里发现博客园的makedown语法支持还不完善,代码语法显示挺有问题的,比较遗憾. 标题 # 一级标题## 二 ...

  5. mysql 的数据文件

    mysql的数据文件 由于mysql的数据文件结构主要跟mysql的存储引擎相关,这里不做过多解释,具体查看各个引擎章节的内容 .首先上一段小辉老师的教程; 在MySQL 中每一个数据库都会在定义好( ...

  6. 垃圾回收 GC

    垃圾回收器的回收的对象: 垃圾回收只回收托管堆中的内存   什么样的对象才会被回收? 没有变量引用的对象.没有变量引用的对象,表示可以被回收了(null.   什么时间回收? 不确定,当程序需要新内存 ...

  7. Flex 教程(1)-------------控件拖动

    今天和大家分享下关于在Flex中 针对控件的拖动开发. 1.需要在 .mxml文件中编写一个Button按钮 如下代码: <s:Button id="button1" lab ...

  8. 【BZOJ】【1101】【POI2007】Zap

    莫比乌斯反演 PoPoQQQ的讲义例一的一半……好吧这题是那题的基础部分= =很水…… WA了一次:因为没强制类型转换LL /************************************* ...

  9. Class Object

    java.lang Class Object java.lang.Object public class Object Class Object is the root of the class hi ...

  10. HDU 1385 Minimum Transport Cost (最短路,并输出路径)

    题意:给你n个城市,一些城市之间会有一些道路,有边权.并且每个城市都会有一些费用. 然后你一些起点和终点,问你从起点到终点最少需要多少路途. 除了起点和终点,最短路的图中的每个城市的费用都要加上. 思 ...