Get information about a SHA-1 commit object?

Solution 1:

git show <SHA1> will show the commit date, author, parent, and diff of files that changed from parent commit.

Solution 2:

git show --no-patch --oneline <SHA1>
git show --no-patch <SHA1>

This is an answer to View a specific Git commit which has no reply box as it has been marked as a duplicate of this question. Some of the people looking for a reply to the above question are likely to follow the link and look for an answer here.

Both are questions about obtaining information about a commit from its SHA1 code.

Some of the time when you have identified a commit by its SHA1 code, you will want to know everything about it: all the changed files, what the actual changes are etc.

The other question is much more specific. Someone had a suspect line of software in a file and had tracked it to a particular SHA1 code using "git blame". They then simply wanted to know which software change in human terms had introduced that line. There is no interest in knowing all the other changed files, no interest in getting a complete diff of the files, or even of getting a diff of that one file. It's simply about knowing which change introduced a line of code.

Instead of information like

c27feeaa9b2c6270ff559b21eaf9f1e0317676a7

we want information like

Humanitarian Aid Feature

or

Left handed Thread Fix

To do that, use

git show --no-patch --oneline <SHA1>

where git show --no-patch (i.e. with the --no-patch option) is the key to answering eykanal's question View a specific Git commit

Use

git show --no-patch <SHA1>

if you want author and date information too.