The best answers to the question “How can I show what a commit did?” in the category Dev.
A stupid way I know is:
git diff commit-number1 commit-number2
Is there a better way?
I mean, I want to know the commit1 itself. I don’t want to add the commit2 before it as a parameter.
$ git log -p
do what you need?
Check out the chapter on Git Log in the Git Community Book for more examples. (Or look at the the documentation.)
Update: As others (Jakub and Bombe) already pointed out: although the above works, git show is actually the command that is intended to do exactly what was asked for.
git show <commit-id>
Documentation for git show
I found out that “git show –stat” is the best out of all here.
It gives you a brief summary of the commit and what files you added and modified without giving you whole bunch of stuff, especially if you changed a lot files.
git show <commit>
To show what a commit did with stats:
git show <commit> --stat
To show commit log with differences introduced for each commit in a range:
git log -p <commit1> <commit2>
Each commit has a unique id we reference here as
<commit>. The unique id is an SHA-1 hash – a checksum of the content you’re storing plus a header. #TMI
If you don’t know your
git logto view the commit history
Find the commit you care about.