簡體   English   中英

如何在git中查找文件的最近提交者?

[英]how to find recent committers of a file in git?

有沒有辦法找到誰最近在 git 中更改了文件?

例如,我需要最后 5 個更改此文件的人。 我嘗試了git annotategit blame但我找不到我想要的確切內容。

可能不是最有效或最明智的方式,但這似乎有效:

$ git log <filepath> | grep Author: | cut -d' ' -f2- | uniq | head -n5

這是假設您實際上想要最后 5 個author ,而不管他們每個人可能進行了多少次提交。 如果您只想要最后 5 次提交,則可以單獨使用git log

$ git log -5 <filepath>

git shortlog 做你想要的:

git shortlog -sne <filename>

嘗試:

git log filename

您可以使用日志輸出(參見 man git-log)來獲取您想要的信息。

我發現這對於顯示單個文件的最后 5 個作者很有用

git log -n 5 --pretty='format:%an' -- path/to/file

-n <number> - 要顯示的提交數(在本例中為作者)

--pretty='format:%an' - 只顯示作者姓名

我在用着

 gitk filename

托爾斯滕

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM