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
| Flag | Meaning |
|---|---|
| --stat | file summary instead of the full patch |
| --name-only | list the paths the commit touched |
| -s | message only, no diff |
| <commit>:<path> | print the file as it was in that commit |
| --pretty=fuller | show author and committer dates separately |
Examples
git show HEADthe message and diff of the last commit
git show HEAD~2:src/app.tsprints an old version of a file without touching your copy
git show --stat v1.2.0what 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