How can I show what a commit did?

Git

Git Problem Overview


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 Solutions


Solution 1 - Git

git show <commit-id>

Documentation for git show

Solution 2 - Git

Does

$ git log -p

do what you need?

Check out the http://git-scm.com/book/en/Git-Basics-Viewing-the-Commit-History">chapter on Git Log in the Git Community Book for more examples. (Or look at the http://git-scm.com/docs/git-log">the documentation.)

Update: As others (https://stackoverflow.com/users/46058/jakub-narebski">Jakub</a> and https://stackoverflow.com/users/43582/bombe">Bombe</a>;) already pointed out: although the above works, http://www.kernel.org/pub/software/scm/git/docs/git-show.html">git show is actually the command that is intended to do exactly what was asked for.

Solution 3 - Git

TL;DR

git show <commit>


Show

To show what a commit did with stats:

git show <commit> --stat

Log

To show commit log with differences introduced for each commit in a range:

git log -p <commit1> <commit2>

What is <commit>?

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 <commit>:

  1. git log to view the commit history

  2. Find the commit you care about.

Solution 4 - Git

I found out that git show <commit> --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.

Solution 5 - Git

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

Solution 6 - Git

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>^!

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSam LiaoView Question on Stackoverflow
Solution 1 - GitBombeView Answer on Stackoverflow
Solution 2 - GitMark van LentView Answer on Stackoverflow
Solution 3 - GitGeoffrey HaleView Answer on Stackoverflow
Solution 4 - GitHarvey LinView Answer on Stackoverflow
Solution 5 - Git1800 INFORMATIONView Answer on Stackoverflow
Solution 6 - Gitwat erView Answer on Stackoverflow