有时候想快速查看某个提交中,修改了哪些文件,而又不想打开git图形管理工具,那么直接两个命令就可以搞定了。
查看某次提交中,修改了哪些文件,可以分以下几个步骤:
1. 通过 git log 获取提交的 commit id
jason@local Dos$ git log
commit 33edda5b930d5a366e5d5913cb64e961c6800743
Author: Jason Wang <xxxxx@qq.com>
Date: Tue Jun 25 17:53:28 2019 +0800
提交测试说明
附加说明:
- 提交id 即: SHA-1 校验和(33edda5b930d5a366e5d5913cb64e961c6800743)
- 作者的名字和电子邮件地址
- 提交时间
- 提交说明
2. 使用 git show [commit id] | grep diff | cut -d" " -f 3 查看提交的信息
jason@local Dos$ git show e626c5adb3c9e4e01dca599e78513394a7e06e16 | grep diff | cut -d" " -f 3
a/application/common/controller/xxx.php
a/application/test/controller/xxxx.php
或者 git show e626c5adb3c9e4e01dca599e78513394a7e06e16 | grep diff | awk '{print $3}'
附加说明
git show e626c5ad 命令,如果不经过筛选的话,返回内容如下
jason@local Dos$ git show e626c5adb3c9e4e01dca599e78513394a7e06e16
commit e626c5adb3c9e4e01dca599e78513394a7e06e16 (HEAD -> master, origin/master, origin/HEAD)
Author: Jason Wang <xxx@qq.com>
Date: Wed Jun 26 09:47:02 2019 +0800
提交测试说明
diff --git a/application/common/controller/Pdf.php b/application/common/controller/Pdf.php
index a1cbd4b..3af7ee6 100644
--- a/application/common/controller/xxx.php
+++ b/application/common/controller/xxx.php
@@ -326,11 +326,11 @@ class xxx extends a {
- public function getCover(){
+ public function getCover($model){
- <b>Aaaaaa</b></span>
+ <b>Abbbbb</span>
diff --git a/application/test/controller/Index.php b/application/test/controller/Index.php
index e565710..1a4fb88 100644
--- a/application/test/controller/xxx.php
+++ b/application/test/controller/xxx.php