How can I show what a commit did?

Viewed 198548

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.

6 Answers

Does

$ 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.

This is one way I know of. With git, there always seems to be more than one way to do it.

git log -p commit1 commit2

The answers by Bomber and Jakub (thanks!) are correct and work for me in different situations.

For a quick glance at what was in the commit, I use

git show <replace this with your commit-id>

But I like to view a graphical diff when studying something in detail and have set up a "P4diff" as my Git diff. I then use

git diff <replace this with your commit-id>^!
Related