An Overview of Git – Core Concepts of Distributed Version Control System

Git is a distributed version control system (DVCS) and source code management system with an emphasis on speed. A Version Control System (VCS) enables you to record changes to a file over time. Git was initially designed and developed by Linus Torvalds. In this tutorial, you will learn basic concepts of Git.

Git is a version control system for tracking changes in computer files and coordinating work on those files among multiple people. Git is not Github. Git is the version control software. Github is a git repository hosting service which offers all the features provided in git. Github is where you upload your git repositories.

DVCS local clients not only check out the latest snapshot of the files but they can make fully mirror of the remote repository. If the server goes down, then the repository from any client can be copied back to the server to restore it. Every checkout is a full backup of the repository. Git does not rely on the central server and that is why you can perform many operations when you are offline. You can commit changes, create branches, view logs, and perform other operations when you are offline. You require network connection only to publish your changes and take the latest changes.

Advantages of Git

Below are the few advantages of Git.

  • Free and open source
  • Security
  • Implicit backup
  • Easier branching
  • No need of powerful hardware

Git Workflow

We have three conceptual areas of Git.

  • Working Directory or Working Tree 
  • Staging Area (Index)
  • Git Repository

git staging

Working Tree

Working Tree or Working Directory is the location where you are currently working. It is the area where your files resides. Git cannot track this area until files added to staging area. Here if you make changes and do not explicitly save them to git, you will lose the changes that you made to your files. This happens because git is not aware of the files or changes in the Working Tree. If you make changes to files in your working tree, git will recognize that they are modified, but until you tell git to pay attention to these changed files it won’t save anything.

You can get what your working tree contains by executing this command git status. This command will show you two things:

  • Files in your Working Tree
  • Files in your Staging Area
git status

Staging Area (Indexing)

Staging Area or Indexing is the area where git starts tracking and saving changes that happen in files. These made changes reflect in the .git directory (Hidden Directory in Unix like OS). You ask git that I want to track these specific files, then git says okay and moves these files from you working directory to the Staging Area. However, if you make more additional changes after adding a file to the Staging Area, git will not know those specific changes until you ask to see them. Means you have to again add these modified files to the staging area.

You can get what your staging area contains by executing this command git status. you can add files to your Staging Area by running the command git add #filename# . It will add a specific file to the Staging Area from your Working directory. If you want to add everything from the Working Tree, then run the command git add . . The . (dot) operator is a wildcard meaning all files.

git add .

Git Repository

Git repository has two kind of repositories.

  • Local Repository
  • Remote Repository

Local Repository

Local Repository resides on your local machines. There is no central repo you need access to do your work. You can commit, branch, etc on your own repo on your local machine even without internet access. The .git directory contains everything. Local Repository has all of your checkpoints or commits. It is the area that saves everything (so do not try to delete it).

You can add files from the staging area to your Local Repository using this command git commit. It takes all changes in the Staging Area, wraps them together and puts them in your Local Repository. After committing, your Staging Area will be empty.

git commit -m "description"

Remote Repository

Remote repository is a common repository that all team members used to exchange their changes in files. In most cases, remote repositories are stored on a code hosting service like GitHub, Gitlab etc. After commiting changes to the local repository you can push the files to remote directory so that other team members can view your files.

To add files from your local repository to remote repository you can use this command git push. It asks the credentials to push your local files to remote repository like github. You must have official or personal github or other VCS account to store your local files in remote repositories. You need username and password to push the local files into remote repository.

git push origin master


So you learned all the core concepts of Git in this tutorial. In our next git tutorial we will go through basic to advanced Git commands. Thanks!!!

Read Also :Getting Started with Docker – Basic Commands

Share on:

Ravindra Kumar

Hi, This is Ravindra. I am founder of TheCodeCloud. I am AWS Certified Solutions Architect Associate & Certified in Oracle Cloud as well. I am DevOps and Data Science Enthusiast.

Recommended Reading..

3 thoughts on “An Overview of Git – Core Concepts of Distributed Version Control System”

Leave a Comment