Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Git Tutorial
  • Git Exercises
  • Git Basic Commands
  • Git Cheat Sheet
  • Git Interview Questions
  • Git Bash
  • GitHub
  • Git Branch
  • Git Merge
  • Git WorkFlow
  • Git Hooks
  • Git LFS
  • Git Rebase
  • Git Cherry Pick
Open In App
Next Article:
Git - git-show Command Line Utility
Next article icon

Git - git-show Command Line Utility

Last Updated : 22 Feb, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

Git is a free and open-source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Git relies on the basis of distributed development of software where more than one developer may have access to the source code of a specific application and can modify changes to it that may be seen by other developers. Initially designed and developed by Linus Torvalds for Linux kernel development in 2005.

git show

We use Git in our daily coding activities, however, there are many concepts of Git that are still unknown to people. One such command is git show. Before getting started with what git show is, let us initialize our local directory with git init command and make it a git repository is as depicted below:

When working with Git, we see the .git folder which contains many subdirectories inside it, one such subdirectory is .git/objects directory which contains the information about different types of objects such as blob , trees , commits, and tags.

Blob Object - stores the contents of the file
Tree Object - contains a list of all files in our repository with a pointer to                the blob object assigned to them
Commit Object - points a pointer to its tree object
Tag Object - show the tag message and other objects                included in the tag(object name, object type, tag name)

To view expanded details on these objects we use the command git show. Let us understand more about the command with the help of an example.

We have created a file named demo.txt, wrote 2 lines in it, and committed the changes.

Let's now use git show command and see what all information we get using the command.

git show <commit id>

We can see that there is a lot of information that we got when we use git show command. From the above image, we can infer that git show command shows us 2 things 

  • Part 1: The commit message and the pointer to which the HEAD is pointing.
  • Part 2: Second thing that can see is the different versions of the file .

Let's discuss the 2 parts to some depth as follows:

PART 1 

The first part gives us the same result as when we type the git log command which tells us about the commit history of the commit id. 

HEAD -> master   Tells us about the pointer where the HEAD is currently pointing.

Since this commit had a pointer to the HEAD, let's see another example of git show where the commit doesn't have a pointer to the HEAD.

We didn't get HEAD->master here as this commit is not pointing to the HEAD.

PART-2 

As we can see that this part starts with diff --git a/demo.txt b/demo.txt .

  • diff here means the difference, difference in between the file that is pointing to HEAD.
  • a/demo.txt and b/demo.txt show the 2 versions of the file demo.txt.

git diff command in git is used to track the difference between the changes made on a file. It shows the changes  between the commits, working tree, branches, files .

One can try and check git show command by trying it on various commit ids. 


Next Article
Git - git-show Command Line Utility

A

atharvapaliwal7
Improve
Article Tags :
  • Git

Similar Reads

    How to Install Git on Windows Command Line?
    Git is an open-source and free, decentralized version control system designed to handle projects of all sizes with speed and efficiency. Basically, it is a software tracking application that is commonly used to monitor projects across several teams. The best way of downloading and installing Git on
    3 min read
    How to Dry Run Git Commands?
    Git is used for version control in software development. Understanding the effects of Git commands before executing them can help prevent mistakes and ensure that your repository remains in a good state. This is where "dry running" Git commands become incredibly useful. A dry run simulates the execu
    3 min read
    Using Git on CommandLine
    Git is very important and powerful tool when it comes to the software development life cycle. Now in this article, we are going to see why git is used vastly in the software industry and what kinds of operations we can perform with git. So git is basically a distributed version control system for tr
    5 min read
    How To Get The Git Commit Count?
    Tracking the number of commits in your Git repository can provide insights into the development progress, team activity, and overall project health. Whether you want to get the total commit count or see the number of commits by each contributor, Git offers several ways to retrieve this information.
    2 min read
    How to Setup Git Using Git Config?
    Git is a powerful version control system that helps developers manage their code efficiently. To use Git effectively, you need to configure it properly using the git config command. This setup ensures that Git recognizes your identity, preferred settings, and workflow preferences.How the git configu
    3 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences