问题
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