2

Suppose I have a file mocky.cpp, I would like to list commits that modified the file, and also list another files that were touched by these commits. So I try the following:

git log --name-only -- mocky.cpp

I get a list of commits, that is nice, strangely, however, all the commits do not modify a file except from mocky.cpp. I check one of them, say, e013aac, w/ git show e013aac and I find out it also changes testy.hpp. Moreover, I found that git show e013aac -- mocky.cpp only outputs the diff for the mocky.cpp but not for the testy.cpp
This is most counter-intuitive to me, anyway, how could I achieve what I wanted in the first place?

4

2 回答 2

2

我不知道这是否是最实用的,但下面的命令可能会做你想要的:

for SHA in $(git log --format='%H' your_file.cpp) ; do git diff-tree --name-only -r $SHA ; done
于 2013-08-17T18:57:01.253 回答
1

尝试:

git log --format=%H -- mocky.cpp | xargs git show --stat

或根据您的需要对其进行修改,例如:

git log --format=%H -- mocky.cpp | xargs git show --name-only
于 2013-08-17T18:35:14.007 回答