Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find out what files changed in a given git commit?

Tags:

git

I am troubleshooting a problem where something that used to work, does not, all of a sudden. Given a sha1, how can i find out what files changed as part of it?

like image 962
James Raitsev Avatar asked Mar 23 '26 08:03

James Raitsev


2 Answers

Any of these should work:

git diff-tree --no-commit-id --name-only -r <COMMIT_SHA1>

git show --pretty="format:" --name-only <COMMIT_SHA1>

Example output:

foo
bar
baz

To also show the status of each file in the change, use --name-status option instead:

git diff-tree --no-commit-id --name-status -r <COMMIT_SHA1>

git show --pretty="format:" --name-status <COMMIT_SHA1>

Example output:

A     foo
M     bar
D     baz
like image 168
Tuxdude Avatar answered Mar 25 '26 22:03

Tuxdude


git show --name-only <the-hex-sha1-string> should do the trick. Here I assume that sha1 you mention is the sha1 signature of the commit.

Consider reading about git bisect for further troubleshooting.

like image 43
9000 Avatar answered Mar 25 '26 22:03

9000



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!