laktak laktak - 3 months ago 10
Git Question

How to see the changes in a commit?

When I do

git diff COMMIT
I see the changes between that commit and HEAD (afaik) but I would like to see the changes that were made by that single commit.

I haven't found any obvious options on diff/log that will give me that output.

Answer

To see the diff for a particular COMMIT hash:

git diff COMMIT^ COMMIT will show you the difference between that COMMIT's ancestor and the COMMIT. See the man pages for git diff for details about the command and gitrevisions about the ^ notation and its friends.

Alternatively, git show COMMIT will do something very similar. (The commit's data, including its diff.) See the git show manpage.