使用 GIT 获得Linux Kernel的代码并查看,追踪历史记录
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的代码并查看,追踪历史记录的更多相关文章
- ubuntu 下 使用 Git 维护 linux kernel版本
学习linux内核一段时间,意识到内核的版本需要严格控制.利用Git工具可以很轻松的完成不同开发人员不同模块之间的代码融合与版本控制 . 1. 首先,安装Git .可以参考廖雪峰的博客 https: ...
- 拥抱开源,怎样关注Linux Kernel 邮件列表?
现在开源如此火爆.以至于张口闭口不提到都仿佛不是搞IT 的.那么怎样拥抱开源?本文适合刚開始学习的人,如有大神至此,goto exit ! 一.怎样增加开源 以Linux 为例,这么一个成功的开源项目 ...
- Linux Kernel代码艺术——系统调用宏定义
我们习惯在SI(Source Insight)中阅读Linux内核,SI会建立符号表数据库,能非常方便地跳转到变量.宏.函数等的定义处.但在处理系统调用的函数时,却会遇到一些麻烦:我们知道系统调用函数 ...
- Linux Kernel 代码艺术——编译时断言
本系列文章主要写我在阅读Linux内核过程中,关注的比较难以理解但又设计巧妙的代码片段(不关注OS的各个模块的设计思想,此部分我准备写在“深入理解Linux Kernel” 系列文章中),一来通过内核 ...
- arm linux kernel 从入口到start_kernel 的代码分析
参考资料: <ARM体系结构与编程> <嵌入式Linux应用开发完全手册> Linux_Memory_Address_Mapping http://www.chinaunix. ...
- Linux Kernel系列 - 黄牛X内核代码凝视
Hanks.Wang - 专注于操作系统与移动安全研究.Linux-Kernel/SELinux/SEAndroid/TrustZone/Encription/MDM Mail - byhank ...
- Linux kernel Vhost-net 和 Virtio-net代码详解
场景 Host上运行qemu kvm虚拟机,其中虚拟机的网卡类型为virtio-net,而Host上virtio-net backend使用vhost-net 数据包进入虚拟机代码分析 首先看vhos ...
- Linux kernel的中断子系统之(七):GIC代码分析
返回目录:<ARM-Linux中断系统>. 总结: 原文地址:<linux kernel的中断子系统之(七):GIC代码分析> 参考代码:http://elixir.free- ...
- Linux Kernel 代码艺术——编译时断言【转】
转自:http://www.cnblogs.com/hazir/p/static_assert_macro.html 本系列文章主要写我在阅读Linux内核过程中,关注的比较难以理解但又设计巧妙的代码 ...
随机推荐
- Python GUI编程实践
看完了<python编程实践>对Python的基本语法有了一定的了解,加上认识到python在图形用户界面和数据库支持方面快捷,遂决定动手实践一番. 因为是刚接触Python,对于基本的数 ...
- NGUI3.5系列教程之 一些小功能的实现
(一)可拖动窗体的实现: 1:添加一个Sprite为鼠标点击区域,改名为:DragSprite 2:给DragSprite添加Collider 3:给DragSprite添加Drag Object , ...
- DB天气app冲刺二阶段第十一天(完结)
今天最后一天冲刺了,明天就不再冲刺了..已经把所有的技术的问题还有设计的问题都弄好了吧应该说 至少目前来说是的.因为有的实现不了的或者需要耗费时间的已经果断舍弃了,然后需要完善的也都基本完善了. 现在 ...
- 如何编写好的jQuery代码
本文就是自己看,如果您不小心进到了这里,请看源处,是这个作者翻译的:http://blog.sae.sina.com.cn/archives/4157 讨论jQuery和javascript性能的文章 ...
- ios显示艺术字字体颜色渐变
UIColor * myColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"123.jpg"]]; self. ...
- FFmpeg在Android上的移植之第一步
http://blog.sina.com.cn/s/blog_69a04cf40100x1fr.html 从事多媒体软件开发的人几乎没有不知道FFmpeg的,很多视频播放器都是基于FFmpeg开发的. ...
- html利用锚点实现定位代码实例
本章节介绍介绍一下如何利用锚点实现定位,使用锚点实现定位是html固有的功能,当然比较简单,也实现了基本的功能,但是功能相对简单一些,如果想要实现平滑的定位可以参阅jquery实现的点击页面动画方式平 ...
- 【POJ】【2151】Check the difficulty of problems
概率DP kuangbin总结中的第8题 一开始题目看错导致想转移方程想错了……想成f[i][j]表示前 i 个队伍中最多的做出来 j 道题的概率……sigh 看了下题解……其实是对于每个队伍 i 单 ...
- java和javascript真的有关系=。=
相同点:1. 内存管理,两者都采用GC来对内存进行回收.因此Java与javascript的内存泄露情况十分相似. 2. 代码编译为机器码后由中间件执行:Java使用前会编译为字节码后由JVM执行,V ...
- linux vi修改后如何保存
linux vi修改后如何保存 按ESC键去到命令模式,然后: :w?? 保存文件但不退出vi :w file 将修改另外保存到file中,不退出vi :w! 强制保存,不推出vi :wq 保存文件并 ...