Let's Understand How Git Maintains History Of Version Or Commit Ids 📥📤 With Details


In my previous article, I described more details on Git's complete flow, how to push changes from local git to GitHub, and what git add, git commit, git status, and git push commands. Also, I describe how the developers share code from a single repository.

In this article, I will describe the below-mentioned points in detail.

  1. How Git maintains a history of versions or commits IDs
  2. How Git maintains a controlling system
  3. How Git maintains commit IDs during push changes from local Git to GitHub

Note. Before going through this session, please visit my below-mentioned session related to Git and GitHub.

  1. Introduction To Git
  2. Steps For Configuring Git With Details
  3. Let's Know About Git Add, Git Commit, Git Status, And Git Push-In Details

Git maintains Version IDs or Commit IDs

Now, we go to the Local Dev One workspace and try to pull the latest changes and see what happens as shown below

 Local Dev

It shows the message that it's already up to date. That means there are no new changes available in the GitHub repository. If you go to the local git repository that .git directory then you find a file called HEAD as shown below.

GitHub repository

There you can see one ref path that is refs/heads/main. So, We need to go this path and find the file called main as shown below.


Here in the main File, you can see the commit ID is 993a754918f12e841eeab79cbd125720e96347f3. That is nothing but the Version ID. As per an earlier discussion, Git is a version-controlling system and it maintains a version for each modification we perform.

So, If we go to the GitHub repository and check this version ID is 993a754918f12e841eeab79cbd125720e96347f3 as shown below.

First, click on 3 commits.

3 commits

Here you the version ID in the short format as shown below. So, To see the details of version ID click on Changes made by Local Dev One.

Local Dev One

So, after clicking on Changes made by Local Dev One, you can see the version id in detail in the code section as well as the in-browser URL.

Browser URL

The same commit id is shown in both the local Git repository and GitHub repository as earlier discussed. Now, we see what these + and - symbols are inside the content of files in the GitHub repo.

GitHub repo

Here Local Dev One wants to modify a file called MyFile.cs as shown below.


Here we check the status to see the modified file as shown below. The details of untracked files and Changes not staged for a commit are described in the previous article.

Modified file

Let's commit this MyFile.cs to the stage area as shown below. The below commands are described in the previous article.


Now let's go to the local .git repository and check the commit ID in the main file of this path is refs/heads/main. There you can see the different commits as per the latest changes made in MyFile.cs as shown below.

Different commits

So, every time Git maintains a different version ID based on each modification and tracks the history. So, Git is called a version-controlling system. Now we check the same version ID should be there in the GitHub repository. For this, the file should be pushed from local git to the GitHub repository as shown below.

 Git maintains

As of now, I have one branch called main which is the default one instead of the command that is git push origin main, We can give it only as git push. But when there are many branches and we need to push changes to a specific branch of the GitHub repository then we should follow this command git push alias name of git repo branch name. According to this format I have given git push origin main. Here origin is the alias name of the git repo and the main is the branch name. As I already have pushed the changes using a command that is git push. So, here when I run using a command that is git push origin main then it shows Everything up-to-date. That means there are no new changes available in a local git repository.

Now if I go to my GitHub repository then I can see the latest changes with comments added during commit changes.

The message I have given.

Latest changes

The added content in MyFile.cs.

Added content

You can see a total of 4 commits and click on the latest commit to check the new Version ID or commit ID as the same as local git.

Version ID

Now you can see the new commit ID as shown below. Also, there is showing 1 changed file with 2 additions and 0 deletions. There is 2 addition which means two + symbols. One symbol means there is one new line space and another plus symbol means for new property country name added.\ Here we can see both the commit IDs are the same.

Commit IDs

Now Local Dev One wants to remove one line in MyFile.cs as shown below.

Remove one line

Then push these changes from local git to the GitHub repository using the same steps as described earlier.

Local git to GitHub

Now let's see the changes made in the file MyFile.cs and what this - symbol means. It shows 1 changed file with 0 additions and 1 deletion. Here deletion means the Local Dev one has removed the PostId property line from the MyFile.cs file.

 PostId property line

Here we can see the user name with day and time details who has committed the changes e.g. satyaCsgithub committed 17 minutes ago as shown below.

SatyaCsgithub committed


In this write-up, we have learned the below details.

  • How Git maintains the history of version or commit IDs
  • How Git maintains a controlling system
  • How Git maintains commit IDs during push changes from local Git to GitHub
  • What addition and deletion symbol means

Thank You & Stay Tuned For More

Similar Articles