Git blame on files/folders level?

偶尔善良 提交于 2019-12-11 11:48:12

问题


Is it possible to git blame on a files/folders level instead of the "line by line"-level?

The command git blame usually shows the last commit affecting each line in a given document, but what I'm wondering is whether you get a list of what was the last commit affecting each file. Judging from the options it is not possible to do using git blame but is there some other command that might do something similar?

EDIT: Ideally I'd like to get a list with the file names where for each file we also get the commit hash, the name of the person who edited the file last as well as the date.


回答1:


Not sure it suits your needs but

git log -1 --pretty=format:"%an" -- path/to/file

would output the name of the last person having modified the file (or directory).

Edit after comments :

To loop over files of a directory, in a bash context, use xargs :

git ls-files path/to/directory/ | xargs -n 1 git log -1 --pretty=format:"%h %an %cd" --

...and optionnally, just slightly easier for the eyes with a justified middle column :

git ls-files path/to/directory/ | xargs -n 1 git log -1 --pretty=format:"%h %<(20,trunc)%an %cd" --


来源:https://stackoverflow.com/questions/55573181/git-blame-on-files-folders-level

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!