Git?

Aditi Dosi
3 min readSep 1, 2022

--

Git is free and open source software for distributed version control: tracking changes in any set of files, usually used for coordinating work among programmers collaboratively developing source code during software development.

What is Git and why is it used?

Git is a DevOps tool used for source code management. It is a free and open-source version control system used to handle small to very large projects efficiently. Git is used to tracking changes in the source code, enabling multiple developers to work together on non-linear development.

There are two types of version control systems:

  • Centralized. All team members connect to a central server to get the latest code copy and share their contribution with others.
  • Distributed. In a distributed VCS, every team member has a copy of the project and its history on their machine, allowing them to save snapshots of the project locally.

The issue with a centralized VCS is the single point of failure. If the server goes down, team members can’t collaborate or save snapshots of their project.

The following diagram shows how multiple people collaborate in a single project using Git:

Git is a distributed VCS that resolves the single point of failure issue because it allows members to synchronize their work even if the central server is offline.

How Does Git Work?

How it handles data is what differentiates Git from other version control systems.

While other VCSs store information as a list of file-based changes, Git stores its data in a series of snapshots of a miniature filesystem. Every time you commit a change or save your project state, Git takes a snapshot of all your files at that moment and stores a reference to that snapshot.

If there were no file changes, for the sake of efficiency, Git doesn’t store the file again. Instead, it only creates a link to the previous file version, which is already stored.

A Git project resides in three sections:

  • The Working Directory. The single checkout of one version of the project.
  • The Staging Area. An index that stores information about what the next commit will contain.
  • The Git Repository. The place where Git stores the metadata and object database for a project.

Before storing data in Git, everything is checksummed and then referred to using that checksum. This prevents any file changes or data corruption from going under the radar. The mechanism used for checksumming is the SHA-1 hash.

Git stores files in three main states:

  • Modified. A file has been changed but not yet committed to the database.
  • Staged. A modified file in its current version is marked to go into the next commit snapshot.
  • Committed. The data is safely stored in your local database.

The VCS also prevents data loss because almost all actions in Git only add data to the repository, making them basically undoable.

Conclusion

You should know the basic features of Git, how it works, and why it is important.

If you are working on a collaborative project with several development paths, having a VCS is mandatory, and Git is the best one on the market.

--

--