joachim
joachim

Reputation: 30903

How to see single commit changes made in a file?

I want to see the changes that were made to a specific file in a commit.

git show SHA shows me too much. git show SHA:FILENAME is no good because that shows the entire file, not the diff.

Upvotes: 1

Views: 142

Answers (2)

Joseph K. Strauss
Joseph K. Strauss

Reputation: 4913

The simplest way:

git show SHA -- /path/filename

If it is a merge commit:

git show -m --first-parent SHA -- /path/filename

This will also show the summary of the commit. To just see the diff add --format=''

If you use this often, config and use and alias (feel free to use your own alias):

git config --global alias.diffsha 'show -m --first-parent --format=""'
git diffsha SHA -- /path/filename

Upvotes: 2

Dario
Dario

Reputation: 4035

You can try with:

git diff SHA^ SHA /path/filename

... to compare changes between commit ref SHA and his previous SHA^ for a specific path (you can also use wildcards).

Upvotes: 0

Related Questions