Coding Programming Knowledge

The Three Stages of Git Version Control

March 25, 2019

Many people usages git everyday. But very few people know how it works! Mostly coders or more specifically git users uses some command to create commit and sync with the remote repository. Although it is working for them, they soon fall into problems. As they do not know why it was working in the first place, they could not find any solution what so ever when in trouble. But to solve a problem we need to know the working procedure. That is why, every one should know the Git stages which helps the git version control system to determine which files to commit and how!

In the Git version control system, there are three areas where our code lives. These are called namely – Working Area, Staging Area, and Repository.

3 Git Stage

Working Area

The Git version control system does not handle files that are in the Working area only. That means the Git does not track them. That is why these files are sometimes called untracked files.
Generally, programmers do not includes, ./bin folder or /vscode folder (generated by VS Code IDE) or any other IDE generated files because they are not relevant. The easy way to do it is by using .gitignore file. I’ll Talk about it later.

Staging Area

Git tracks The files that are in the staging area. Git analyse those files to check what has changed between the current commit and the last commit.


In this stage, the git version control system has all your commits and it knows what has been changed in the commit. It is the snapshot of what you changed in a commit.

How Staging area works?

The staging area is how git knows what will change between the current commit and the next commit. It has the last commits hash. So whenever new files are added or deleted or someone just edits a file, it immediately knows that something is changed. Because the new generated SHA1 (hash) is different.

Moving files In and Out of the staging area

As we are talking about staging area, some might ask how do we add or remove a file from the staging area. It’s quite simple!

  • To add File in the next commit
    • git add <file>
  • To delete a file in the next commit
    • git rm <file>
  • To rename a file in the next commit
    • git mv <file>

Git add -p

This is one of the tools when you’ve done too much work for one commit. It let’s you add files to the staging area interactively. Here a screenshot.

Interactive Git Add
Unstaging and staging cycle

When you are removing a file from the staging area, it doesn’t mean it will get deleted. It just returned to working area. That’s all!

How Content Moves in GIT

A generic view of how git works between stages

You Might Also Like

No Comments

Leave a Reply