日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

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

發(fā)布時間:2024/9/19 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 git log 查看某文件的修改历史 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

先進(jìn)入此文件所在的目錄下

1. git log --help??

所有的git命令都可以通過git manual查看

在synopsis中可以看到公式 ?git log [<options>] [[--] <path>] 其中 []中的內(nèi)容可以為空?

每個option都有相應(yīng)的解釋

?git log --help

?

?

GIT-LOG(1) Git Manual GIT-LOG(1)NAMEgit-log - Show commit logsSYNOPSISgit log [<options>] [<revision range>] [[--] <path>...]DESCRIPTIONShows the commit logs.The command takes options applicable to the git rev-list command to control what is shown and how, andoptions applicable to the git diff-* commands to control how the changes each commit introduces areshown.OPTIONS--followContinue 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 nameprefixes refs/heads/, refs/tags/ and refs/remotes/ will not be printed. If full is specified, thefull ref name (including prefix) will be printed. The default option is short.:

?

?

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

可以看到該文件相關(guān)的commit記錄

git log -- README.md?

?

?

commit 83bb011fac7cd4b94c7e711fc1b4457c43b0e60d Author: lin <542072149@qq.com> Date: Fri Jun 2 10:47:11 2017 +0800測試Change-Id: Ifbbb04e664407bb89f726bf967d2847ed211a949commit 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 filename

可以顯示該文件每次提交的diff

?git log -p README.md?

?

?

commit 83bb011fac7cd4b94c7e711fc1b4457c43b0e60d Author: lin <542072149@qq.com> Date: Fri Jun 2 10:47:11 2017 +0800測試Change-Id: Ifbbb04e664407bb89f726bf967d2847ed211a949diff --git a/README.md b/README.md index 565897b..85c6bcf 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,9 @@ add a liness新加一行, 完善一下for ticket 11 - +UUUhometest 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: Iafb710f80d7970d052a0298ece955ce1fc3840eddiff --git a/README.md b/README.md index 8b79f6f..565897b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@Add a little contentSrebase iadd a line - +ss新加一行, 完善一下for ticket 11(END)

?

5.git show?commit-id

? ? ? 根據(jù)commit-id查看某個提交?

?

6. gitk --follow filename

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

?

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

8.git log 的常用選項(xiàng)

?

選項(xiàng)說明

-p

按補(bǔ)丁格式顯示每個更新之間的差異。

--stat

顯示每次更新的文件修改統(tǒng)計信息。

--shortstat

只顯示 --stat 中最后的行數(shù)修改添加移除統(tǒng)計。

--name-only

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

--name-status

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

--abbrev-commit

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

--relative-date

使用較短的相對時間顯示(比如,“2 weeks ago”)。

--graph

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

--pretty

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

?

選項(xiàng)說明

-(n)

僅顯示最近的 n 條提交

--since,?--after

僅顯示指定時間之后的提交。

--until,?--before

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

--author

僅顯示指定作者相關(guān)的提交。

--committer

僅顯示指定提交者相關(guān)的提交。

--grep

僅顯示含指定關(guān)鍵字的提交

-S

僅顯示添加或移除了某個關(guān)鍵字的提交

?

總結(jié)

以上是生活随笔為你收集整理的git log 查看某文件的修改历史的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。