使用 GIT 获得Linux Kernel的代码并查看,追踪历史记录 (转载)

本文详细介绍如何使用Git获取Linux Kernel源代码,并演示了基本的Git操作流程,包括克隆仓库、查看状态、创建分支、提交更改及查看历史记录等。

使用 GIT 获得Linux Kernel的代码并查看,追踪历史记录

 

 

转载:http://blog.youkuaiyun.com/caspiansea/article/details/25172615

Linux kernel  的官方 GIT地址是:

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

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

1. 拿代码仓库

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

2. 查看状态:
  1. $ git status  
  2. # On branch master  
  3. nothing to commit (working directory clean)  

3. 更新本地的代码:
  1. $ git pull  
  2. Already up-to-date.  

4. 切换到分支:
  1. $ git checkout linux-3.10.y   
  2. Checking out files: 100% (25952/25952), done.  
  3. Switched to branch 'linux-3.10.y'  
5. 查看分支信息:
  1. $ git branch    
  2. * linux-3.10.y  
  3.   master  
  1. $ git branch  -a  
  2. * linux-3.10.y  
  3.   master  
  4.   remotes/origin/HEAD -> origin/master  
  5.   remotes/origin/linux-2.6.11.y  
  6.   remotes/origin/linux-2.6.12.y  
  7.   remotes/origin/linux-2.6.13.y  
  8.   remotes/origin/linux-2.6.14.y  
  9.   remotes/origin/linux-2.6.15.y  
  10.   remotes/origin/linux-2.6.16.y  
  11.   remotes/origin/linux-2.6.17.y  
  12.   remotes/origin/linux-2.6.18.y  
  13.   remotes/origin/linux-2.6.19.y  
  14.   remotes/origin/linux-2.6.20.y  
  15.   remotes/origin/linux-2.6.21.y  
  16.   remotes/origin/linux-2.6.22.y  
  17.   remotes/origin/linux-2.6.23.y  
  18.   remotes/origin/linux-2.6.24.y  
  19.   remotes/origin/linux-2.6.25.y  
  20.   remotes/origin/linux-2.6.26.y  
  21.   remotes/origin/linux-2.6.27.y  
  22.   remotes/origin/linux-2.6.28.y  
  23.   remotes/origin/linux-2.6.29.y  
  24.   remotes/origin/linux-2.6.30.y  
  25.   remotes/origin/linux-2.6.31.y  
  26.   remotes/origin/linux-2.6.32.y  
  27.   remotes/origin/linux-2.6.33.y  
  28.   remotes/origin/linux-2.6.34.y  
  29.   remotes/origin/linux-2.6.35.y  
  30.   remotes/origin/linux-2.6.36.y  
  31.   remotes/origin/linux-2.6.37.y  
  32.   remotes/origin/linux-2.6.38.y  
  33.   remotes/origin/linux-2.6.39.y  
  34.   remotes/origin/linux-3.0.y  
  35.   remotes/origin/linux-3.1.y  
  36.   remotes/origin/linux-3.10.y  
  37.   remotes/origin/linux-3.11.y  
  38.   remotes/origin/linux-3.12.y  
  39.   remotes/origin/linux-3.13.y  
  40.   remotes/origin/linux-3.14.y  
  41.   remotes/origin/linux-3.2.y  
  42.   remotes/origin/linux-3.3.y  
  43.   remotes/origin/linux-3.4.y  
  44.   remotes/origin/linux-3.5.y  
  45.   remotes/origin/linux-3.6.y  
  46.   remotes/origin/linux-3.7.y  
  47.   remotes/origin/linux-3.8.y  
  48.   remotes/origin/linux-3.9.y  
  49.   remotes/origin/master  

6. 创建一个新分支:
  1. $ git checkout -b linux-3.10-charles   
  2. Switched to a new branch 'linux-3.10-charles'  
  1. $ git branch   
  2. * linux-3.10-charles  
  3.   linux-3.10.y  
  4.   master  
7. 修改文件 init/main.c, 加入一行注释,然后 执行
  1. git add .  
  1. $ git status  
  2. # On branch linux-3.10-charles  
  3. # Changes to be committed:  
  4. #   (use "git reset HEAD <file>..." to unstage)  
  5. #  
  6. #   modified:   init/main.c  
  7. #  

  1. e$ git add -i  
  2.            staged     unstaged path  
  3.   1:        +2/-0      nothing init/main.c  
  4.   
  5. *** Commands ***  
  6.   1: [s]tatus     2: [u]pdate     3: [r]evert     4: [a]dd untracked  
  7.   5: [p]atch      6: [d]iff   7: [q]uit   8: [h]elp  
  8. What now>   

如果选择  revert 命令,相当于 undo  "git add .":
  1. What now> r  
  2.            staged     unstaged path  
  3.   1:        +2/-0      nothing [i]nit/main.c  
  4. Revert>>   
  5. reverted one path  
  6.   
  7. *** Commands ***  
  8.   1: [s]tatus     2: [u]pdate     3: [r]evert     4: [a]dd untracked  
  9.   5: [p]atch      6: [d]iff   7: [q]uit   8: [h]elp  
  10. What now> q  
这个时候再执行 git status:
  1. $ git status  
  2. # On branch linux-3.10-charles  
  3. # Changes not staged for commit:  
  4. #   (use "git add <file>..." to update what will be committed)  
  5. #   (use "git checkout -- <file>..." to discard changes in working directory)  
  6. #  
  7. #   modified:   init/main.c  
  8. #  
  9. no changes added to commit (use "git add" and/or "git commit -a")  

8. 提交修改:
  1. $ git commit -a -m "This is just for testing git"  
  2. [linux-3.10-charles 9eabb78] This is just for testing git  
  3.  1 file changed, 1 insertion(+), 1 deletion(-)  
9. 查看修改记录(git log):
  1. commit 9eabb788b5c33efed589b1263aedd69b97e592ac  
  2. Author: Taotao Ding <htdkd@hotmail.com>  
  3. Date:   Wed May 7 03:36:55 2014 +0900  
  4.   
  5.     This is just for testing git  
  6.   
  7. commit 5d897eedc505bb8af1f4865ae381eadbfd3bc8c1  
  8. Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>  
  9. Date:   Tue May 6 07:56:24 2014 -0700  
  10.   
  11.     Linux 3.10.39  
  12.   
  13. commit 6b32172a1d3cffa74067ced96612bd13658d4fcf  
  14. Author: Felipe Balbi <balbi@ti.com>  
  15. Date:   Tue Feb 25 10:58:43 2014 -0600  
  16.   
  17.     usb: musb: avoid NULL pointer dereference  
  18.       
可以看到,修改已经被记录起来了。
  1. git log  -p  
  2. commit 9eabb788b5c33efed589b1263aedd69b97e592ac  
  3. Author: Taotao Ding <htdkd@hotmail.com>  
  4. Date:   Wed May 7 03:36:55 2014 +0900  
  5.   
  6.     This is just for testing git  
  7.   
  8. diff --git a/init/main.c b/init/main.c  
  9. index e83ac04..febc1e9 100644  
  10. --- a/init/main.c  
  11. +++ b/init/main.c  
  12. @@ -10,7 +10,7 @@  
  13.   */  
  14.    
  15.  #define DEBUG          /* Enable initcall_debug */  
  16. -  
  17. +/* This is a test line for git */  
  18.  #include <linux/types.h>  
  19.  #include <linux/module.h>  
  20.  #include <linux/proc_fs.h>  

10: 查看一个文件最近的修改记录:
  1. $ git log master..HEAD init/main.c  
  2. commit 9eabb788b5c33efed589b1263aedd69b97e592ac  
  3. Author: Taotao Ding <htdkd@hotmail.com>  
  4. Date:   Wed May 7 03:36:55 2014 +0900  
  5.   
  6.     This is just for testing git  
  7.   
  8. commit b7a52f5111bc53ffbfff96330621cbde80df6ba4  
  9. Author: Theodore Ts'o <tytso@mit.edu>  
  10. Date:   Tue Sep 10 10:52:35 2013 -0400  
  11.   
  12.     random: run random_int_secret_init() run after all late_initcalls  
  13.       
  14.     commit 47d06e532e95b71c0db3839ebdef3fe8812fca2c upstream.  
  15.       
  16.     The some platforms (e.g., ARM) initializes their clocks as  
  17.     late_initcalls for some unknown reason.  So make sure  
  18.     random_int_secret_init() is run after all of the late_initcalls are  
  19.     run.  
  20.       
  21.     Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>  
  22.     Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>  

11: 比较两个分支的差异:
  1. $ git log linux-3.10.y..linux-3.10-charles   
  2. commit 9eabb788b5c33efed589b1263aedd69b97e592ac  
  3. Author: Taotao Ding <htdkd@hotmail.com>  
  4. Date:   Wed May 7 03:36:55 2014 +0900  
  5.   
  6.     This is just for testing git  

当前分支也可写成  HEAD,所以:
  1. $ git log linux-3.10.y..HEAD  
  2. commit 9eabb788b5c33efed589b1263aedd69b97e592ac  
  3. Author: Taotao Ding <htdkd@hotmail.com>  
  4. Date:   Wed May 7 03:36:55 2014 +0900  
  5.   
  6.     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)


 

转载于:https://www.cnblogs.com/linux-home/p/5404646.html

内容概要:本文系统介绍了算术优化算法(AOA)的基本原理、核心思想及Python实现方法,通过图像分割的实际案例展示了其应用价值。AOA是一种基于种群的元启发式算法,其核心思想来源于四则运算,利用乘除运算进行全局勘探,加减运算进行局部开发,通过数学优化器加速函数(MOA)和数学优化概率(MOP)动态控制搜索过程,在全局探索与局部开发之间实现平衡。文章详细解析了算法的初始化、勘探与开发阶段的更新策略,提供了完整的Python代码实现,结合Rastrigin函数进行测试验证。进一步地,以Flask框架搭建前后端分离系统,将AOA应用于图像分割任务,展示了其在实际工程中的可行性与高效性。最后,通过收敛速度、寻优精度等指标评估算法性能,提出自适应参数调整、模型优化和行计算等改进策略。; 适合人群:具备一定Python编程基础和优化算法基础知识的高校学生、科研人员及工程技术人员,尤其适合从事人工智能、图像处理、智能优化等领域的从业者;; 使用场景及目标:①理解元启发式算法的设计思想与实现机制;②掌握AOA在函数优化、图像分割等实际问题中的建模与求解方法;③学习如何将优化算法集成到Web系统中实现工程化应用;④为算法性能评估与改进提供实践参考; 阅读建议:建议读者结合代码逐行调试,深入理解算法流程中MOA与MOP的作用机制,尝试在不同测试函数上运行算法以观察性能差异,可进一步扩展图像分割模块,引入更复杂的预处理或后处理技术以提升分割效果。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值