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. 转:一份基础的嵌入式Linux工程师笔试题

    一. 填空题: 1. 一些Linux命令,显示文件,拷贝,删除 Ls cp rm 2. do……while和while……do有什么区别? 3. Linux系统下.ko文件是什么文件?.so文件是什么 ...

  2. SVN备份教程(三)

    上次的博文SVN备份教程(二)中,我们讲解了一下SVN定时备份的相关内容,同时我们又提出了一种新的SVN备份方案--自动备份. 1.简介 所谓自动备份,它实现的思路非常简单,就是利用SVN自带的hoo ...

  3. 【转发】SSH无密码登录的配置

    免责声明:     本文转自网络文章,转载此文章仅为个人收藏,分享知识,如有侵权,请联系博主进行删除.     原文作者:http://cn.soulmachine.me/     原文地址:http ...

  4. Linux命令zip和unzip

    问题描述:        使用Linux中命令zip和unzip 问题解决: 命令名: zip  功能说明:压缩文件. 语 法:zip [-AcdDfFghjJKlLmoqrSTuvVwXyz$][- ...

  5. C# memcache

    概述 memcache是一套开放源的分布式高速缓存系统.由服务端和客户端组成,以守护程序(监听)方式运行于一个或多个服务器中,随时会接收客户端的连接和操作.memcache主要把数据对象缓存到内存中, ...

  6. [转载]C# 多线程、控制线程数提高循环输出效率

    C#多线程及控制线程数量,对for循环输出效率. 虽然输出不规律,但是效率明显提高. 思路: 如果要删除1000条数据,只使用for循环,则一个接着一个输出.所以,把1000条数据分成seed段,每段 ...

  7. curPos和tgtPos

    curpos tgtpos 乍一看以为是当前位置和目标位置,但在项目里面这两个位置有点坑 当客户端玩家移动或者AI里面的位置,会把获得的位置付给tgtpos 而以前的tgtpos会付给curpos 所 ...

  8. Codeforces Round #363 (Div. 2)->C. Vacations

    C. Vacations time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  9. KASS分布式文件系统(Kass File System)

    KASS分布式文件系统(Kass File System),简称KFS,是开始公司自主研发的分布式文件存储服务平台.KFS系统架构及功能服务类似Hadoop/GFS/DFS,它通过HTTP-WEB为上 ...

  10. hibernate里createSQLQuery

    一.addEntity()和setResultTransformer()方法 1. 使用SQLQuery 对原生SQL查询执行的控制是通过SQLQuery接口进行的,通过执行Session.creat ...