The git show
command provides detailed information about a specific commit, such as changes made, the author, date, and commit message. It is useful for examining the content of a particular commit in more depth compared to the git log
.
Initial Example
$ git show <your_commit_hash>
SHOW Options
Option | Description |
---|---|
--pretty | Customize the log output format. Possible values: oneline , short , full , fuller , etc. |
--stat | Show statistics for files modified in the commit. |
--patch , -p | Show the full diff of the commit. |
--name-only | Show only the names of the files that were changed. |
--name-status | Show the names and status of files that were changed. |
--abbrev-commit | Show only the first few characters of the SHA-1 hash. |
--relative-date | Show dates relative to the current time (e.g., “2 weeks ago”). |
--no-commit-id | Suppress the commit ID in the output. |
--source | Show the source of the commit (branch/tag). |
--full-diff | Show the full diff, not just the patch. |
--color | Show colored diff output. |
Examples
1. Show Details of a Specific Commit
Displays detailed information about the specified commit.
$ git show abc1234
Replace abc1234
with the actual commit hash you want to view.
2. Show Changes in a Specific File
Shows changes made to a specific file in the given commit.
$ git show abc1234:path/to/file
Replace abc1234
with the commit hash and path/to/file
with the file path.
3. Show Details with Patch
Displays detailed information along with the full patch (diff) of the specified commit.
$ git show --patch abc1234
Replace abc1234
with the actual commit hash.
4. Show Details of the Most Recent Commit
Displays detailed information about the latest commit on the current branch.
$ git show