Anviam Blog

If you are a developer then you must heared the name of “Git”. Here I am going to talk about git and its related terms.

So, What is Git ?
Git is a free and open source distributed version control system. It is created by Linus torvalds, the same person who created Linux kernel in 2005.

what is version control system?
Version control system is a category of software tools that helps record changes to file or set of files by keeping track of modifications done to the code.
It allows multiple developers, designers, and team members to work together on the same project.

Why we need version control system?
->It is important when you are collaborating with team to keep yourself updated with the code and flow of the project.
->For storing versions of code after making changes.so that you can go back to any particular version of the code any time in future.
->For backup of your project.

Three are mainly two types of version control systems.
1.)Central version control system (CVCS)
2.)Distributed version control system (DVCS)

Diagram : Central Version Control System


Central version control system : These kind of systems have centralized server that contains all the versioned files. All the clients checkout files from that central place. The main drawback of these kind of systems is single point of failure that the centralized server represents. If the system goes down then nobody can collaborate during that time and save anything to the system. And if the hard disk of the system gets corrupted then we can lost everything. Some examples of that kind of systems are CVS, Subversion, and Perforce.

Diagram : Distributed Version Control System


Distributed version control system : Distributed systems were basically created to overcome the drawbacks of central version control systems by fully mirroring the system on every clients system. So that if any server dies then we can copy everything from any client back to server. Some examples of that kind of systems are Git, Mercurial, Bazaar or Darcs.

So i hope now you get the basic idea of why we need git.

How we will use git?
Git bash (for windows)
Git shell (for ios)

Both of these are command line programs for interacting with git using git commands. So if you have windows then use Git bash and if you have ios then use Git shell.

Now we will talk about some terms related to git which are very important to understand git properly.

Repository/repo : A repository/repo is a directory that contains your project work and some meta data and it can exist either on local machine or remote machine.

Commit : Commit is basically taking the snapshot of all the files at that particular moment of time so that you can go back to that state any time in future.

Stagging index : The Stagging index is the file where all the changes that you will be commiting next are stored. It helps you to review all the changes before commit.

Working directory : The working directory is your current local directory that you are working on. When you work on your code editor you are basically working on working directory.

Branch : A branch is essentially an independent line of development. You can take advantage of branching when working on new features or bugs.

Checkout : Checkout is used for the act of switching between different versions of a repository/repo. Checking out a branch updates the files in the working directory to match the version stored in that branch

Push : The “push” command is used to upload new local commits on a remote repository. Publishing and uploading local changes to a remote server is known as pushing.

Pull : The “pull” command is used to fetch and download content from a remote repository and immediately update the local repository to match that content. This is known as pulling.

So these was the mostly used terms in git. Now, before starting to work with git commands you first need to install git. For installing git please go to this official git website. https://git-scm.com/downloads

After installing git on your machine, we need to create repository. There are two ways to create repository.

Initializing a Repository in an Existing Directory :- If you want to turn your existing local directory to repository then use the following command. git init

Cloning an Existing Repository :- If you want clone the existing directory from remote server, then use the following command. git clone <URL of your remote repository>

So now we have created repository, go ahead and explore more commands of git.

Leave a Reply

Your email address will not be published. Required fields are marked *