Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
Version Control System
3.
Benefits of Version Control System
4.
What is Git?
4.1.
How to install Git?
4.2.
How to configure Git?
5.
What is GitHub?
6.
Frequently asked questions
7.
Key Takeaways 
Last Updated: Mar 27, 2024

Version Control

Introduction

As the name suggests, Version Control System is a system for maintaining different versions of a codebase.

Let us understand this with an example:

Imagine there is a multinational company which has its offices all over the world with thousands of employees. In such a big company, there will be a set of issues and challenges it may face. So, what could be the possible challenges a company faces?

  1. Collaboration: There will be so many people located at different offices in a company. There may be a need to communicate for a particular reason or a set of people working on the same project but from other regions.
  2. Storing versions: A project is not completed in a single version. There may be 'n' number of versions. In that case, the problem of storing all those commits in the same place is a considerable challenge.
  3. Restoring previous versions: Sometimes, it is essential to go back to the earlier versions to find the root cause of any bug. 
  4. Backup: In case the system or the user's disk breaks down, and there is no backup, all the efforts will go in vain. 

 

As a solution, the version control system comes into the picture!!

Version Control System

Version control refers to software tools that allow developers to look after the changes made to the source code. The system records all the changes made to a file or set of files, so later, a specific version may be called. It is the responsibility of the version control system to keep all the team members on the same wavelength. It makes sure that everyone on the team is working on the latest version of the files and, most importantly, makes sure that all these people can work together simultaneously on the same project.

Let's understand version control with a graphical example:

There are three workstations or developers at three different locations. There is one repository that is acting as a server. The developers are using the repository for either committing or updating the task. Each workstation has its working copy, and all these workstations will be saving their code in a particular server repository. This makes it easy for any developer to access the task being done using the repository. In case the system of any specific developer breaks down, there will be a copy of the source code in the central repository.

Benefits of Version Control System

Now, let's check out some benefits of using a version control system:

  1. The first and foremost advantage of a version control system is that it helps manage and protect the source code by keeping track of the modification made to the source code. Version control also covers the source code from human error and its consequences.
  2. It keeps track of all the changes made to the source code in all versions. The team is continuously producing new source codes and making amendments to the already existing code. All these changes are to be recorded for future reference if they need it to get to the primary cause of the problem or bug.
  3. The third advantage is comparing earlier versions of the code. As we know, all the earlier versions are saved in the version control system. This makes it possible for the developers to go back to compare the earlier versions of the code to help rectify the mistake while reducing inconvenience to all team members.
  4. The version control system support developer's way of working and not aby rigid working system

 

Git is one of the most renowned version control systems. We shall look at Git in detail!!

What is Git?

Git is one of the version control systems available in the market which is free and distributed. Git was developed in 2005 by Linus Torvalds, the famous creator of the Linux operating system kernel. Git is the most widely used modern version control system. A significant number of software projects that rely on Git include commercial projects as well as open-source.

How to install Git?

To use Git, we first need to install it. It can be downloaded from their official website. We can download the latest version of Git for the corresponding operating system from the given options.

Alternatively, it can be downloaded and installed using the command line. The command varies from OS to OS.

How to configure Git?

After having installed Git, we can verify it with the help of the following command:

git --version

 

Next, we'll have to set our username and email address. Git uses this information to store who made the changes. To set username and email address, use the following command:

Username

git config --global user.name "username"

 

Email Address:

git config --global user.email "email"

 

Replace the "username" with your username and "email" with your email address.

Voila!! Your git version control is ready to be used.

What is GitHub?

GitHub is a website for hosting Git repositories online. Suppose you are working on a project at home and suddenly remembering the answer to a code mistake that has been bothering you for days while you are away, perhaps at a friend's house.

Because your PC is not with you, you cannot make these adjustments. However, if your project is hosted on GitHub, you may access and download it using a command on any computer you have access to. Then make your modifications and publish the most recent version to GitHub.

In conclusion, GitHub allows you to host your repository on their platform. Another fantastic benefit of GitHub is the opportunity to interact with other developers from anywhere in the world.

Check out most important Git Interview Questions here.

Frequently asked questions

1.What are the two categories of version control systems?

Ans: The version control systems are categorized in to two categories

  1.  Distributed( decentralized)
  2. Centralized


2. Is Git the only version control system?

Ans: No, Git is not the only existing version control system available in the market. Other version control systems are Beanstalk, Perforce, AWS CodeCommit, etc.

3. What is the difference between Git and GitHub

?Ans: Git is a version control system, and GitHub is a website for hosting Git repositories.

Key Takeaways 

 Version control refers to the types of software tools that allow developers to look after the modifications made to the source code.

Git is the most widely used version control system.

GitHub is a website for hosting Git repositories.

For more interesting technical blogs, stay tuned to Coding Ninjas Blogs!!

Happy Learning!

Live masterclass