因为想查看某一个函数对应在源码中的修改记录,就想到了git log.试试看能不能搜索到相关信息。

想找到一个内核函数相关的git log修改记录,第一想法是"git log + grep"操作:

zhugeyifan@83-28:~/source/linux-stable/linux-stable$ git log | grep interruptible_sleep_onswim3: fix interruptible_sleep_on raceinterruptible_sleep_on is racy and going away. This replaces the oneThe interruptible_sleep_on_timeout in DAC960_gam_ioctl seems equivalentinterruptible_sleep_on is racy and going away. In the arv driver thatparport: fix interruptible_sleep_on raceThe interruptible_sleep_on function is can still lead to the[hans.verkuil@cisco.com: replaced interruptible_sleep_on_timeout by[media] radio-cadet: avoid interruptible_sleep_on race...

搜索出来的信息非常的零散,无法去查看具体的某一个提交记录等。

这样并没有什么用...还有没有什么办法?


按提交信息检索

后来找到一个好的办法:

git log --grep=xxx

按提交信息来过滤提交,你可以使用 --grep 标记。

它会搜索git log中的提交信息,并将匹配上的信息整段git log显示出来,非常的方便!

实例:

比如说,我现在需要搜索内核代码中的interruptible_sleep_on的提交记录,我就可以用下面这个命令来显示这个 interruptible_sleep_on相关的所有提交:

zhugeyifan@83-28:~/source/linux-stable/linux-stable$ git log --grep=interruptible_sleep_on
commit 106fd892bc714a9b7c28daba98a3623a41c32f1a
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Wed Feb 26 12:01:44 2014 +0100swim3: fix interruptible_sleep_on raceinterruptible_sleep_on is racy and going away. This replaces the onecaller in the swim3 driver with the equivalent race-freewait_event_interruptible call. Since we're here already, thisalso fixes the case where we get interrupted from atomic context,which used to just spin in the loop.Signed-off-by: Arnd Bergmann <arnd@arndb.de>Cc: Jens Axboe <axboe@kernel.dk>Signed-off-by: Jens Axboe <axboe@fb.com>commit 9c552e1ddd3658944787d75d90a42e1a2b74b7ea
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Wed Feb 26 12:01:43 2014 +0100DAC960: remove sleep_on usageSigned-off-by: Arnd Bergmann <arnd@arndb.de>Cc: Jens Axboe <axboe@kernel.dk>Signed-off-by: Jens Axboe <axboe@fb.com>commit 9c552e1ddd3658944787d75d90a42e1a2b74b7ea
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Wed Feb 26 12:01:43 2014 +0100DAC960: remove sleep_on usagesleep_on and its variants are going away. The use of sleep_on() inDAC960_V2_ExecuteUserCommand seems to be bogus because the commandby the time we get there, the command has completed already andwe just enter the timeout. Based on this interpretation, I concludedthat we can replace it with a simple msleep(1000) and rearrange thecode around it slightly.The interruptible_sleep_on_timeout in DAC960_gam_ioctl seems equivalentto the race-free version using wait_event_interruptible_timeout.I left the driver to return -EINTR rather than -ERESTARTSYS to preservethe timeout behavior.Signed-off-by: Arnd Bergmann <arnd@arndb.de>Cc: Jens Axboe <axboe@kernel.dk>Signed-off-by: Jens Axboe <axboe@fb.com>
...

这些内容相比之前的信息,真的充实了很多!


当然,git中还有很多类似的搜索“关键字”的命令

按作者进行搜索:

当你只想看某一特定作者的提交的时候,你可以使用 --author 标记。它接受正则表达式,返回所有作者名字满足这个规则的提交。如果你知道那个作者的确切名字你可以直接传入文本字符串:

git log --author="John"

按文件进行搜索:

很多时候,你只对某个特定文件的更改感兴趣。为了显示某个特定文件的历史,你只需要传入文件路径。比如说,下面这个命令返回所有和 foo.py 和 bar.py 文件相关的提交:

git log -- foo.py bar.py

按范围进行搜索:

你可以传入范围来筛选提交。这个范围由下面这样的格式指定,其中 <since> 和 <until>是提交的引用:

git log <since>..<until>

参考朝西的生活:https://www.jianshu.com/p/f2fa0a590370

【开发工具】【git】通过关键字搜索对应的git提交日志相关推荐

  1. 唯品会API开发系列:item_search-按关键字搜索vip商品API 返回值说明

    为了进行电商平台唯品会(VIP)的API开发,首先我们需要做下面几件事情. 1)开发者注册一个账号 2)然后为每个唯品会(VIP)应用注册一个应用程序键(App Key) . 3)下载唯品会(VIP) ...

  2. Linux——(二)环境基础开发工具(yum,vim,gcc,gdb,makefile,git)

    本节目录 总述 1. yum:软件包管理工具 1.1 软件包是什么? 1.2 软件包的操作 1.2.1 查看 1.2.2 安装 1.2.3 卸载 2. vim:linux编辑器 2.1 vim基本概念 ...

  3. notepad写php为什么不变色,【编程开发工具】notepad关键字不变色怎么办

    NotePad++关键字变色 1.点击设置→语言格式设置 2.在打开的语言格式设置界面中,选择语言:下面的java,在style:中选择TYPE WORD,(这一步很关键)见下图中蓝色部分. 3.在下 ...

  4. php 编辑器格式输出_高效PHP开发人员的十大PHP开发工具

    图说:怎样选择最好的PHP开发工具 PHP是用于构建网站与Web应用程序最快,并且使用最广泛的服务器端脚本语言. 有几个很好的理由可以说明开发人员更喜欢PHP或一些其他的脚本语言,例如Python和R ...

  5. 开发工具篇第九讲:菜鸟入坑指南

    摘要:本文是开发工具篇第九讲:菜鸟入坑指南.针对新人上手慢的问题,写了这篇入坑指南,方便自己回顾,总结.本文分为四个部分,分别为jenkins使用技巧:常用软件操作命令:开发手册:调试手册.主要材料来 ...

  6. 统一vscode和hbuildX开发工具格式化规则

    项目中格式化规范建议 以vscode和hbuildX为例,建议统一采用prettier格式化插件. 目的:用于适应一个项目组不同开发人员选择不同开发工具做出格式化统一标准.方便git仓库代码管理. 建 ...

  7. Git详解之七:自定义Git

    原文:<Pro Git> 自定义 Git 到目前为止,我阐述了 Git 基本的运作机制和使用方式,介绍了 Git 提供的许多工具来帮助你简单且有效地使用它. 在本章,我将会介绍 Git 的 ...

  8. git show HEAD^num和个git show HEAD~num的区别

    为什么80%的码农都做不了架构师?>>>    今天学习Git时遇到了这么一个问题,最后反过来重新查看前面的讲解终于弄明白了.其实主要是没有搞清楚什么是第一父提交和第二父提交. [f ...

  9. linux篇【3】:Linux 环境基础开发工具yum,vim,gcc,makefile,git

    目录 一.Linux 软件包管理器 yum 1.什么是软件包 2.centos 7中安装形式 3.yum安装好处: 4.yum工具的常用选项 (1)yum list | grep sl 软件包信息介绍 ...

最新文章

  1. ECLIPSE启动不了,报错org.eclipse.swt.SWTException: Invalid thread access
  2. linux 7za下载,Linux安装7za
  3. 关于单车创新的一两点思考
  4. 将DOS批处理文件转换为Shell脚本
  5. [Domino]Java访问Domino必需配置的服务器设置
  6. Catlike Coding网站文章解析 -- 1.Procedural Grid
  7. 小鹏汽车9月总交付10412台 成为新造车势力中第一家月交付过万的企业
  8. 南昌大学c语言大作业,南昌大学计算机C语言答案2
  9. Bailian3703 寻找平面上的极大点【最值】
  10. Unity游戏框架设计
  11. redis5 外部不能连接_基本拧紧技术,螺纹连接也有大不同!
  12. [转]CxImage使用指南
  13. 微信小程序如何上传图片
  14. 复杂句变简单句 java_【SAT写作】简单句如何变为复杂句?10招教你快速转变
  15. 比360强力删除还暴力的删除文件(夹)方法
  16. java零基础学习第九天
  17. Chome浏览器播放语音、视频无声音的解决办法
  18. Cesium 填挖方分析
  19. 谁再说不熟悉 Linux 命令,就把这个给他扔过去!
  20. Exception: Please shut down the controller which is running on port 6653:

热门文章

  1. 山东科技大学OJ题库 1219 体重正常吗?
  2. Aries(白羊座)框架的学习之路-1
  3. xlsx插件将页面表格导出为xlsx文件格式简单案例
  4. Python数据可视化之Pygal图表类型
  5. 前端实现pdf在线批注|画笔|添加文字|添加矩形|添加圆形|定制图形|缩放|撤销恢复|保存批注|下载等功能
  6. vue 项目找不到模块(Module not found)
  7. VMware克隆虚拟机步骤
  8. Android图片加载神器之Fresco,基于各种使用场景的讲解
  9. Fio使用和结果分析
  10. 软件测试职业发展规划和前景的7个阶段