Git归咎于文件/文件夹级别? [英] Git blame on files/folders level?

查看:110
本文介绍了Git归咎于文件/文件夹级别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在文件/文件夹级别而不是逐行"级别进行git blame?

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

命令git blame通常显示影响给定文档中每一行的最后一次提交,但是我想知道的是您是否获得影响每个文件的最后一次提交的列表.从选项来看,无法使用git blame进行操作,但是是否存在其他一些可能执行类似操作的命令?

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?

理想情况下,我想获得一个包含文件名的列表,其中,对于每个文件,我们还获得提交哈希,上次编辑文件的人的姓名以及日期.

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.

推荐答案

不确定是否适合您的需求,但

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).

评论后

要在bash上下文中循环遍历目录文件,请使用xargs:

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" --

这篇关于Git归咎于文件/文件夹级别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆