Home·Terminal commands

git show

git

Usage

git show [<object>|<commit>:<path>]

Prints one commit with its message and diff; the <commit>:<path> form pulls out an old version of a file without touching your working copy.

Common flags

FlagMeaning
--statfile summary instead of the full patch
--name-onlylist the paths the commit touched
-smessage only, no diff
<commit>:<path>print the file as it was in that commit
--pretty=fullershow author and committer dates separately

Examples

git show HEAD

the message and diff of the last commit

git show HEAD~2:src/app.ts

prints an old version of a file without touching your copy

git show --stat v1.2.0

what the tagged commit changed, file by file

The confusion is that undo has several shapes — moving where a branch points is not the same as adding a commit that reverses it.

How to read this

  • Square brackets [ ] mark a part you may leave out.
  • An ellipsis … means you can list more than one.
  • Flags are case-sensitive — in some commands -r and -R do different things.

Questions

Q. What does git show do?

Prints one commit with its message and diff; the <commit>:<path> form pulls out an old version of a file without touching your working copy.

Q. How do I type it?

git show [<object>|<commit>:<path>] — square brackets mark the parts you can leave out.

Q. How many flags are worth knowing?

5 are listed here; the full set is in man git. This command sits under git.

Related commands

man page: man git-show