git log 查看某文件的修改歷史

先進入此文件所在的目錄下git

1. git log --help  app

全部的git命令均可以經過git manual查看工具

在synopsis中能夠看到公式  git log [<options>] [[--] <path>] 其中 []中的內容能夠爲空 測試

每一個option都有相應的解釋spa

 git log --helpcode

 

GIT-LOG(1)                                        Git Manual                                       GIT-LOG(1)



NAME
       git-log - Show commit logs

SYNOPSIS
       git log [<options>] [<revision range>] [[--] <path>...]


DESCRIPTION
       Shows the commit logs.

       The command takes options applicable to the git rev-list command to control what is shown and how, and
       options applicable to the git diff-* commands to control how the changes each commit introduces are
       shown.

OPTIONS
       --follow
           Continue listing the history of a file beyond renames (works only for a single file).

       --no-decorate, --decorate[=short|full|no]
           Print out the ref names of any commits that are shown. If short is specified, the ref name
           prefixes refs/heads/, refs/tags/ and refs/remotes/ will not be printed. If full is specified, the
           full ref name (including prefix) will be printed. The default option is short.

:

 

2. git log -- filename (git log filename)orm

能夠看到該文件相關的commit記錄blog

git log -- README.md ci

 

commit 83bb011fac7cd4b94c7e711fc1b4457c43b0e60d
Author: lin <542072149@qq.com>
Date:   Fri Jun 2 10:47:11 2017 +0800

    測試

    Change-Id: Ifbbb04e664407bb89f726bf967d2847ed211a949

commit 999e31080f96c29d84e11a82e87bfa175976fe0e
Author: lin <542072149@qq.com>
Date:   Fri Apr 21 10:13:19 2017 +0800

    測試
    Change-Id: Iafb710f80d7970d052a0298ece955ce1fc3840ed 

commit 0eaa6ba18abde83622379f152d42f63754a6fd5c 
Author: lin <542072149@qq.com> 
Date: Fri Apr 21 10:12:28 2017 +080

 

3. git log -p filenamerem

能夠顯示該文件每次提交的diff

 git log -p README.md 

 

commit 83bb011fac7cd4b94c7e711fc1b4457c43b0e60d
Author: lin <542072149@qq.com>
Date:   Fri Jun 2 10:47:11 2017 +0800

   測試

    Change-Id: Ifbbb04e664407bb89f726bf967d2847ed211a949

diff --git a/README.md b/README.md
index 565897b..85c6bcf 100644
--- a/README.md
+++ b/README.md
@@ -5,8 +5,9 @@ add a line
 ss
 新加一行, 完善一下
 for ticket 11
-
+UUU

 home

 test and  11
+2017-06-02 10:46

 

4. git show commit-id filename

查看某次提交中的某個文件變化

git show 999e31080f96c29d84e11a82e87bfa175976fe0e README.md

commit 999e31080f96c29d84e11a82e87bfa175976fe0e
Author: lin <542072149@qq.com>
Date:   Fri Apr 21 10:13:19 2017 +0800

    測試

    Change-Id: Iafb710f80d7970d052a0298ece955ce1fc3840ed

diff --git a/README.md b/README.md
index 8b79f6f..565897b 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
 Add a little content
 Srebase i
 add a line
-
+ss
 新加一行, 完善一下
 for ticket 11

(END)

5.git show commit-id

      根據commit-id查看某個提交 

 

6. gitk --follow filename

  以圖形化的界面顯示文件修改列表,

 

7.藉助可視化工具 如 sourceTree 在最後一次修改的記錄上 右鍵選中文件 查看歷史修改

8.git log 的經常使用選項

 

選項 說明

-p

按補丁格式顯示每一個更新之間的差別。

--stat

顯示每次更新的文件修改統計信息。

--shortstat

只顯示 --stat 中最後的行數修改添加移除統計。

--name-only

僅在提交信息後顯示已修改的文件清單。

--name-status

顯示新增、修改、刪除的文件清單。

--abbrev-commit

僅顯示 SHA-1 的前幾個字符,而非全部的 40 個字符。

--relative-date

使用較短的相對時間顯示(好比,「2 weeks ago」)。

--graph

顯示 ASCII 圖形表示的分支合併歷史。

--pretty

使用其餘格式顯示歷史提交信息。可用的選項包括 oneline,short,full,fuller 和 format(後跟指定格式)。

 

選項 說明

-(n)

僅顯示最近的 n 條提交

--since--after

僅顯示指定時間以後的提交。

--until--before

僅顯示指定時間以前的提交。

--author

僅顯示指定做者相關的提交。

--committer

僅顯示指定提交者相關的提交。

--grep

僅顯示含指定關鍵字的提交

-S

僅顯示添加或移除了某個關鍵字的提交

 

 

相關文章
相關標籤/搜索