dkrikun
dkrikun

Reputation: 1328

Check if other files were modified in a commit series in git

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?

Upvotes: 2

Views: 95

Answers (2)

helmbert
helmbert

Reputation: 37944

I don't know if this is best practive, but the command below might do what you intend:

for SHA in $(git log --format='%H' your_file.cpp) ; do git diff-tree --name-only -r $SHA ; done

Upvotes: 2

Alexander Yancharuk
Alexander Yancharuk

Reputation: 14491

Try:

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

Or modify it for your needs like:

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

Upvotes: 1

Related Questions