git 查看提交了哪些文件(命令行 git show)

有時候想快速查看某個提交中,修改了哪些文件,而又不想打開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 命令,如果不經(jīng)過篩選的話,返回內(nèi)容如下

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
最后編輯于
?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

友情鏈接更多精彩內(nèi)容