Distributed Version Control System using GIT GitHub, Git lab

AI Probably
7 min readMay 1, 2020

Hey guys we will see why exactly we should know about Version Control System and Git. If you’re into a service based or else product based company when you’re going to code, you should definitely be aware of the following terms, Version Control system (VCS), GitHub, Git-Lab etc..

It really doesn’t matter if you’re going to work alone or alongside a team in any project (example: open source) there’s always a set of rules, which you’re supposed to follow even if you’re going to make at least one line of code.

Version Control System:

Version Control System is nothing but a software, which does keep track of your files, i.e. at the starting of the project your icon has black colour and finally when your deploy the project it will be having green colour icon, and in the meanwhile there will be a project history created where each version of the project is known as commit (we will discuss this too).

In this example the commit A will be the colourless Icon and after several commits our final output will be commit C (3 commits) we got our coloured icon. Where the difference between the commit A and commit C can even be just a change in one line of code in the entire project. The changes may be small and continuous but still, you should always keep track of what is going on inside the project.

icon example

We can see there are two types of Version Control System,

  • Centralized Version Control Model
  • Distributed Version Control Model

Centralized Version Control Model:

Let’s see this as like a private cloud server which only employees in their organization can work on the project, i.e. every employee will be making some changes in the projects and he / she will update it to the common cloud server.

But this has one big problem i.e. if the central cloud server is corrupted the entire project is lost.

Centralized Version Control Model

Distributed Version Control Model:

Let’s see this as like TensorFlow Model Git Repo, where every one can download i.e. each and every one who’s using TensorFlow or working with TensorFlow has a copy or replication of entire source code so whatever commits and updates he / she does is not going to affect the main source, which is going to be safe and sound.

Distributed Version Control Model

What is GIT ?

Git is an Open Source which has been actively maintained, since 2005. Git is the best example of Distributed Version Control Model. Most of the people usually confuse GIT with GitHub just because of the name. Moreover Git is not only the Version Control System that is available, but this is the most popular one that is available. There are even jobs available just for the version control system.

For anyone whose new to GIT or else working with GIT already, must or should be aware of the 3 partitions and they are,

  • Working Directory → this is where you’re working or making changes in the code, once your done with coding you can add it to the staging area

git add → command to add it in Staging Index

  • Staging Index → this is the area where you will actually have code reviews done, we can also invite people to do code review for us.This can also be done in the working directory and also in the staging area.

git commit → command to commit to the local repository

  • Repository → this is our own local repository, once everything is fine it’s pushed to Master Repo, i.e. everything in this repository is only pushed into the master repository.
Git Repo Architecture

Well consider Staging Area as the virtual environment which you create, where you install TensorFlow (python module) version== 1.15 and in your normal working directory you actually have the TensorFlow version==2.0. This is just an example to get you the picture of why we need a staging area.

What’s GIT HUB ?

It’s a product which provides GIT Repository hosting service provider, where GIT usually works with Command Line and the GIT HUB has it’s Web based GUI. The reason to use this is it provides cloud storage and keeps tracks i.e. it has an easy version control system. It has private as well as public repository.

What is GITLAB ?

This is also a product which provides GIT Repository hosting service, where we can do stuff from project planning, source code management to CI / CD (continuous integration/continuous deployment pipeline feature) as well as monitoring. In simple words it’s just a single application which provides a DevOps — platform which is completely open source.

Advantage over GIT LAB is that it allows free unlimited storage for private repositories and where in GIT HUB it’s paid for private repositories.

Here is a quick comparison of GIT HUB with GIT LAB from their official website,

Ref Link: https://about.gitlab.com/devops-tools/github-vs-gitlab.html

Git Commands with Examples:

GIT Init

This will initialize an empty git repository i.e. it will tell that this is the working directory

git init

git init

You can verify from the following image as shown below

It will be available in hidden files

Git add

This file just adds the files to the staging index from our local / working directory.

git add . → if you use this command then it will add all the files in the working directory to staging index

git add example

git add <file name> → this adds that particular file name to that Repo.

git add 123.jpg image

Git status:

This will tell what is actually in our working directory,

git status

git status

Git Repo history command

git log

It displays the existing commits that we made in the Repo, along with the SHA, the author who made the commit.

git log example

git log — stat

This actually displays the number of files that were added / removed along with the author.

this will open up VIM editor in your command line

Git commit

This allows user to save changes, well it doesn’t do auto save so we manually have to initiate it with a message

git commit -m “your message”

git commit message example

Git Remote

git remote add origin “your git repo URL”

Here you can get the details of the URL which we need to paste.

copy the URL
git remote command examples

For more commands of GIT remote and other stuffs visit official Git website

GIT push

Git push command allows working directory / local repository to be pushed into the remote repo, i.e. into our GitHub / Git Lab web Repos.

git push origin master

Git Clone

It simply makes the copy of the clone to your working directory, in simple words it simply does the ctrl C and ctrl V i.e. copy and paste operation of your local machine.

Here go the git repo and get the repo as shown below with green box,

Copy URL

git clone <URL which you just copied>

git clone URL

Git Config

It is just used to give us the list of configuration of our working directory,

git config — list

git config list

Alternatives of GIT

There are many Version Control System alternatives which are available and they are also open source, like SVN, Mercurial SCM.

SVN is also quite popular like GIT, but it does not follow Distributed Version Control Model it follows Centralized Version Control Model.

On the other hand it is still easier to learn and ain’t that complex like GIT.

When it comes to handling large binary files, GIT is slower when compared to SVN

Both GIT and Mercurial have one great thing in common: both follow Distributed Version Control Model.

Mercurial syntax and the documentation are much simpler to understand when compared with GIT.

But GIT branching is more effective when compared to the Mercurial branching.

So it’s up to you guys to select whichever tool you want.

Note:

If your going to upload from your local PC / working directory to the remote directory like GIT HUB it will allow you to upload only file size of 25 MB.

Yes this also follows some restriction like G-mail

If you wish to say connected, kindly share and follow on,

LinkedIn : https://www.linkedin.com/company/ai-probably/

Twitter : https://twitter.com/aiprobably

Facebook : https://www.facebook.com/aiprobably/

Instagram : https://www.instagram.com/aiprobably/

Website : https://aiprobably.com/

YouTube : https://www.youtube.com/channel/UCVRIJ7lXBgzM61n3dRAgxHw

Author: Narendiran Krishnan / narenltk

--

--

AI Probably

Online Academy for working Professionals #DaretoDream #aiprobably www.aiprobably.com and Subscribe YouTube Channel: youtu.be/dpUbkQ4Q51U