使用 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内核过程中,关注的比较难以理解但又设计巧妙的代码 ...
随机推荐
- java抽象类和接口详解
接口和内部类为我们提供了一种将接口与实现分离的更加结构化的方法. 抽象类与接口是java语言中对抽象概念进行定义的两种机制,正是由于他们的存在才赋予java强大的面向对象的能力.他们两者之间对抽象概念 ...
- Oracle RAC中的一台机器重启以后无法接入集群
前天有个同事说有套AIX RAC的其中一台服务器重启了操作系统以后,集群资源CSSD的资源一直都在START的状态,检查日志输出有如下内容: [ CSSD][1286]clssnmv ...
- C++实现glut绘制点、直线、多边形、圆
C++实现glut绘制点.直线.多边形.圆 必备环境 glut.h 头文件 glut32.lib 对象文件库 glut32.dll 动态连接库 程序说明 C++实现了用glut画点.画直线.画多边形和 ...
- SpringMVC Cache注解+Redis
依赖jar包:Xml代码 收藏代码 <!-- redis --> <dependency> <groupId ...
- Xcode8之后 XMPP 重定义问题 Redefinition of module 'dnssd'
在升级Xcode到8之后,原来的关于XMPP的项目运行报错,错误信息为: Redefinition of module 'dnssd' 系统和XMPP框架同时用到了 'dnssd',大概就是错误的原因 ...
- JDBC 学习笔记(一)—— 基础知识 + 分页技术
本文目录: 1.JDBC简介 2.使用JDBC的步骤——第一个JDBC程序 3.DriverManager ——加载数据库驱动 4.数据库URL ——标识数据库的 ...
- 使用XAMPP本地安装Wordpress博客
最近一直在研究博客,也知道了大名鼎鼎的wordpress,因此也希望动手尝试一下,看看跟网站提供的博客有何区别. 第一个问题:能什么安装wordPress,能否用tocmat? 虽然问题很可笑,但是之 ...
- JS中删除字符串中的空格
问题描述: 在进行字符串操作时,由于字符串中存在较多的空格,因此需要考虑取消字符串中的空格 问题解决: (1)删除字符串中的前导空格(字符串的前面的空格): 注意:这里使用 ...
- [设计模式] 12 代理模式 proxy
在GOF的<设计模式:可复用面向对象软件的基础>一书中对代理模式是这样说的:为其他对象提供一种代理以控制对这个对象的访问.结合上面的游戏代理的例子和下面的图,我们来进行分析一下.以前你是这 ...
- 01-05-01-2【Nhibernate (版本3.3.1.4000) 出入江湖】立即加载实现--NHibernateUtil.Initialize()和添加fetch关键字的HQL查询
相关资料: http://www.cnblogs.com/lyj/archive/2008/10/29/1322373.html 问题的提出: 1.延迟加载,可能会引起session已经关闭的异常,例 ...