Introduction to Git

Introduction to Git

7 mins read524 Views Comment
Updated on Sep 14, 2022 10:01 IST

If you’re new to programming or if you have joined a company recently you might have heard about this term called git- one of the most common tools that individuals use in order to accomplish their tasks.


So, what exactly is Git? Before, answering this question let’s go over the topics that we will be covering in this blog:

  1. What is git? 
  2. Features of Git 
  3. Drawbacks of Git 
  4. How does Git Works? 
  5. Key Git Terminologies 

What is Git? 

Git is a distributed version control system. You can call it a tool that keeps track of the changes made to a computer file. Git was created by Linus Torvald(the same guy who has created the Linux). 

 Now imagine if you wanted to contribute some feature to a project which is being built in collaboration with multiple other team members. At this stage, any of the team members can contribute to the project. So each team member downloads a  copy of the primary source code and can work on their changes locally. So you can also start making changes to your copy of the source code, add your own features and you can submit it. But here comes the problem. In this world, we have millions of programmers and if everyone is trying to work on one software, it becomes pretty messy pretty fast to manage the changes submitted by the developers. And there also comes the issue of malicious code. It is difficult to trust code submissions. Git handles all this by providing features for tracking changes done to the source code.  

You can also explore: Tutorial – How to Use GitHub – Shiksha Online

Features of Git: 

Since Git is the most widely used modern version control system, therefore it is actively maintained and optimized making it one of the most optimized version control solutions available. On top of that, it supports a wide range of operating systems and IDEs. This also makes it quite popular among developers. 

You can also explore: GIT Tutorial for Beginners

The following are the key features of Git: 

  1. Performance: Based on the knowledge of real-world codebases, their design patterns, and how source code gets altered over time, the internal algorithms of git optimize common git activities like branching, committing changes, viewing & comparing application’s version history and merging changes, etc. On top of that git keeps track of the contents of a file, modified file structures, and the metadata associated with the codebase. All these factors make Git a high-performing tool compared to its contemporaries. 
  2. Availability: You do not need any network access to work with git. You can just keep making your changes and committing them and send all the commits to the remote repository with a single push command when you are ready. 
  3. Security: Code integrity is one of the topmost priorities of Git. It is actively maintained by a great team of developers and receives contributions from millions of developers all over the world which helps detect and fix security issues within Git. Git also uses the SHA1  hashing algorithm for encrypting all the data collected by it like the files, commits, tags directories, and versions that protect it from malicious or accidental changes. 
  4. Flexibility: Git can be used for building small and large projects. It is compatible with various operating systems, IDEs, and protocols. It also supports non-linear development workflows. All these characteristics make Git highly flexible for various development environments. 
  5. Open Source: Git is free to use under the public use license. Being open-source, it gives an additional attribute to git for developers to opt for it.  
  6. Scalability: Git is highly scalable if you maintain your git repository in a disciplined manner.  But it is important to keep in mind while using Git, that as the size of the working copy and git repository gets larger, its efficiency is impacted as git needs to keep track of all the files in the repository. 
  7. Supports Collaboration: Git is very nicely designed so that developers can work on a single project in collaboration and keep track of the changes made to the git repository by other contributors.  

Drawbacks of Git: 

Although Git is the best source code management tool out there, there are still some aspects that need to be addressed. Let’s take a look at some of the key drawbacks of using git: 

You can also explore: Git online courses

  1. Combing projects: There still is no elegant solution provided by git for merging the code base of two projects while maintaining the project histories. 
  2. Scalability Bottleneck: As discussed above, scaling a project on git gets difficult as git needs to keep track of the content changes, file changes, tags, commits, and versions histories of the project consequently making it slower as the project gets bigger. 
  3. Difficult to learn: With all the technical terms surrounding git, it gets overwhelming for new developers to grasp the concepts of Git. 
  4. Poor UI: A mild way to put this is that the git user interface is not that pleasant to the eyes. Some prefer it as it gives the raw development feeling and some prefer to have a console for all the git operations. 
  5. Tracking Empty Directories: Git still doesn’t track empty directories. This creates a problem while developing projects where empty directories need to be deployed for storing data from the server.  

How Does Git Work? 

So git works on 3 basic states: 

  1. Local copy: Each developer has a copy of the primary repository (also known as the main branch).  The local copy is your working directory and here you can make the changes and test them.  Most git operations are done on local files only and don’t need to interact with the network. Once the code is ready to be sent for submission, you need to add a snapshot of your code to the staging area. 
  2. Staging Area: This is where your changes are staged. Staging means you have specified which files and changes are to be committed. 
  3. Git Repository: When your changes are staged, they need to be committed permanently to the main directory.  This main repository hosts the code for the live application. Here you can keep track of the code changes, test different versions of the code, and even make changes. 

Take a look at the below diagram for reference: 


Key Terminologies: 

If you are in the process of learning git, it is recommended to make yourself familiar with these keywords that you’ll encounter quite often: 

  1. Branch:  A branch in git is a working directory, where you make your change and test your changes. It basically is a local copy of the remote git repository. A branch is derived from the primary git repository (also known as the main branch). The command git branch <branch name> is used to create a new branch. 
  2. Checkout: The word checkout in the context of git means navigating from one git branch to another. The command git checkout <barnch name> is used to switch from one branch to another. 
  3. Clone: Cloning in git refers to the process of creating a copy of the target repository, locally. The git clone  <repositry URL> is used to create a copy of a git repository. 
  4. HEAD: The HEAD refers to the last commit made to the current branch. This helps keep track of the last changes committed in each branch. 
  5. Main: The Main or the Main branch refers to the default Git branch. This is the branch that gets copied locally while cloning a git project. 
  6. Merge: The process of merging code and file changes from one branch to another is called merging. It is performed using the git merge <target branch> command. 
  7. Origin: The origin keyword is a variable used to refer to the remote main branch. 
  8. Fork: By forking a git repository you can freely debug and test a git project without affecting the original project. 
  9. Pull: Whenever you need to update your working directory with the remote git repository, you need to make a pull. This is done using the git pull <variable name> <branch name> command to make a pull. It fetches all the changes made to the remote repository and merges the same into your local working directory. 
  10. Push: Pushing your code changes means you are sending the data about the file changes that need to be made in the remote branch repository. This updates the code in the remote repository with the changes made to the working directory. The git push <variable name> <branch name> is used for this purpose. 

You can also explore: GitHub/Git Tips and Tricks


In this article we explored the following git concepts: 

  • Introduction to Git 
  • Key features of Git 
  • Drawbacks of Git 
  • Working of Git 
  • Key Git terminologies 
About the Author

This is a collection of insightful articles from domain experts in the fields of Cloud Computing, DevOps, AWS, Data Science, Machine Learning, AI, and Natural Language Processing. The range of topics caters to upski... Read Full Bio