• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

“git show” Command Examples

by admin

The git show command is a versatile tool in Git that allows you to display various types of Git objects, such as commits, tags, trees, and blobs. It provides a detailed view of the content and metadata associated with these objects. Here’s a more detailed explanation of how git show works:

  • Displaying Git Objects: The primary purpose of git show is to display the content and metadata of Git objects. These objects include commits, tags, trees (directory structures), and blobs (file content).
  • Viewing Commits: When you provide a commit hash to git show, it displays detailed information about that commit. This includes the commit message, author, date, and the changes introduced in that commit.
  • Viewing Tags: For annotated tags, git show displays the tag message, tagger information, and the commit associated with the tag. It’s useful for understanding why a tag was created and the corresponding commit.
  • Viewing Trees: Trees represent directory structures in Git repositories. git show can display the contents of a tree, showing the filenames, modes, and the hashes of the objects (either other trees or blobs) within the tree.
  • Viewing Blobs: Blobs represent file content in Git repositories. When you provide the hash of a blob to git show, it displays the actual content of the file.
  • Showing Changes: For commits, git show displays the differences introduced in that commit. This helps you understand what changes were made, line by line.
  • Visualizing Object Contents: git show provides a convenient way to inspect the contents of different Git objects, allowing you to see the details and history of specific objects.
  • Paging Output: If the output of git show is lengthy, it is typically displayed using a pager, such as less, to make it easier to read through the information.
  • Commit Metadata: For commits, git show provides information about the author, committer, commit date, and the commit message.
  • Customizing Output: You can use various options with git show to customize the output, such as specifying a different date format or showing only specific information.
  • Viewing Annotated Tags: git show is often used to view the details of annotated tags, which are tags that have additional metadata, including tagger information and a message.

“git show” Command Examples

1. Show information about the latest commit (hash, message, changes, and other metadata):

# git show

2. Show information about a given commit:

# git show commit

3. Show information about the commit associated with a given tag:

# git show tag

4. Show information about the 3rd commit from the HEAD of a branch:

# git show branch~3

5. Show a commit’s message in a single line, suppressing the diff output:

# git show --oneline -s commit

6. Show only statistics (added/removed characters) about the changed files:

# git show --stat commit

7. Show only the list of added, renamed or deleted files:

# git show --summary commit

8. Show the contents of a file as it was at a given revision (e.g. branch, tag or commit):

# git show revision:/path/to/file

Summary

In summary, git show is a versatile command that allows you to view the details and content of various types of Git objects, including commits, tags, trees, and blobs. It's a valuable tool for inspecting the history, changes, and metadata associated with different objects in your Git repository.

Filed Under: Linux

Some more articles you might also be interested in …

  1. duc: command not found
  2. fmt Command Examples in Linux
  3. modprobe Command Options
  4. git commit: Commit files to the repository
  5. pivpn Command Examples in Linux
  6. kube-fzf: Shell commands for command-line fuzzy searching of Kubernetes Pods
  7. lxc Command Examples in Linux
  8. terminator Command Examples in Linux
  9. mcopy Command in Linux
  10. How to uninstall scons package from Ubuntu

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright