Uncategorized

Beginner Guide For Git & GitHub: Installation, and Commands

In this post, we will be discussing how industries are using Git & GitHub for the version control system.And also exploring the git commands.

What you will learn:

  • Version Control – What & Why
  • Version Control Tools
  • GitHub & Git
  • Case Study: Dominion Enterprises
  • Git Features
  • Git Operations & Commands
  • So let us begin for our first topic,

What is Version Control?

You can consider the version control is a management system which is managing the changes that you have made in your project, documents, computer programs, large websites and other collection of information.

The changes might be adding new files or modifying the older files by changing the source code.

So what does the version control system does that every time you make a change in your project.

It creates a snapshot of your entire project and saves it. These snapshots are actually known as different versions, Now if you are having trouble in word snapshot just consider that snapshot is actually the entire state of your project at a particular time.

look at one example to get a better understanding of version control system or to know version control better.

Let’s say I am developing my own website and at the beginning, I have only one webpage called index.html and After a few days, I have added another webpage called about.html.

Now I had made some changes in about.html like adding some kind of pictures, texts.so version control system detects that some new features are added and few features have been re-edited.

Now again after a few days, I have changed the entire layout of the about.html page so again version control system will detect this update has happened and it will store a snapshot and stores both old and new snapshot.

As per the above example now we have three versions of website which we are working with. so this is how a version control system stores the versions.

Why Version Control?

We have specified the reasons below that why we need version control systems.

Collaboration:

Let’s have a look at the below image we have taken one example

There are three developers working on a particular project and everyone is working on isolation.

There will be conflict when these three developers working on the same folder or same file.

Now the developer one made some changes lets called Xyz, at the same time developer two makes few changes say Abc. So at the end when you try to collaborate and try to merge all of the work together the project will end up with conflicts.

You might not know which developer has made different changes. But with the version control system, it provides you with the shared workspace and it continuously tells you who has made what kind of changes. So you always get notified someone has made a change in your project.

Storing Versions        

This is one of the most important things because of why we need a version control system.

Because saving versions of your project after you have made changes is very essential and without a version control system it can actually get confusing.

Backup

The version control system provides us with(not required) the backup.

Now just look at the diagram below.

The diagram which is shown above is nothing but the typical layout of the version control system.

There is one central server where all the files located and apart from that, the developer has a local copy of all the files that are present in the central server.

So what developer do is that every time they start the coding they fetch all the files from the central server and store it in the local machine after they are done with the work they actually transfer files back to the central server.

If in case your central server gets crashed because some reasons you don’t have to be worry because all the developer have the local copy.

Analyze

The next thing which version control system helps us is to analyze my project because when you finish your project you want to know how your project actually evolved so that you can make analysis to check you can make it better.

Version Control Tools

There is four more popular version control system available in the current market.

1.Git

2.Apache Subversion

3.Concurrent version system (CVS)

4.Mercurial

As you can see by looking at the above image we conclude that git is very much popular nowadays.we have taken this report from google trends.

Let’s learn Git and GitHub 

Let’s have a quick look at the below image which represents what exactly git and Github

GitHub is going to be my central repository and at the other hand, git is going to allow me to create my local repository.

People might get confused between Git and GitHub because they think that it is the same thing, maybe because of the name but actually it is very different.

Well, git is a version control management tool that allows you to perform all operations like fetch data from the central repository server and to just push your files to the central repository server.

Whereas GitHub is just a company that allows us to host your central repository on a remote server.

If you want me to explain in easy word then let’s consider GitHub as a social network which is very similar to facebook, only the difference is that GitHub is a social network for developers.

GitHub Case Study: Dominion Enterprises

Dominion Enterprises is the leading marketing services and publishing company that works across several industries and they have got more than one hundred offices worldwide.

So they have distributed technical team support to develop a range of websites and they include the most popular website homes.com all the dominion enterprises websites actually get more than tens of million unique visitors every month.

Each of the websites which they were working on has a separate development team and all of the developers work independently and each team has its own goals, projects but they actually wanted to share the resources.

They wanted everyone to see what each of the teams is actually working on so basically they want transparency.

Solution

They needed a platform that flexible enough to share the code securely and fo that they adopted the GitHub platform.

The Dominions Enterprises CEO Joe Fuller said that GitHub enterprise has allowed us to store our company’s source code in a central, corporately controlled system.

Having all of their code in one place makes it easier for them to collaborate on projects.

What is Git?

Git is a distributed version control tool that supports distributed non-linear workflows by providing data assurance for developing quality software.

Features of Git

Here are the below some popular features of Git listed:

  • Distributed
  • Compatible
  • Non-linear
  • Branching
  • Lightweight
  • Speed
  • Open-source
  • Reliable
  • Secure
  • Economical

Distributed

This feature allows distributed development of code and Every developer has a local copy of the entire development history and changes are copied from one repository to another.

Compatible

Compatible with existing systems & protocols also SVN and SVK repositories can be directly accessed using git-svn

Non-linear

Supports non-linear development of software and includes various techniques to navigate and visualize non-linear development history.

Branching 

This is the feature where git stands apart from nearly every other control management system because git is the only tool which has a branching model.  

It takes only a few seconds to create & merge branches and master branch always contains production-quality code.

Lightweight

This feature is used lossless compression technique to compress data on the client’s side.

Speed

Fetching the data from local repository is 100 times faster than the remote repository and git is one order of magnitude faster than other version control system tools.

Open Source

Git is an open-source tool that means you can modify its source code according to your needs.

Reliable

On events of a system crash, the lost data can be easily recovered from any of the local repositories of the collaborators.

Secure

Uses SHA1 to name and identify objects and Every file & Commit is checksummed and is retrieved by its checksum at a time of checkout.

Economical

Released under GPL’s license. It is for free and all the heavy lifting is done on the client-side, hence a lot of expenses can be saved on the costly server.

What is a Repository?

A directory or storage space where your projects can live. It can be local to a folder on your computer, or it can be a storage space on GitHub or another online host. You can keep code files, text files, image files, you name it, inside a repository.

There are two types of repositories:

  1. Central Repository
  2. Local Repository

Git Installation And Configuration   

Now let us see the steps to install and configure GIT which is the most popular version control software.

Step 1: To install git using the following command in the terminal.

sudo apt-get install git -y

As you can see GIT is already present in Ubuntu if it is not installed then use the above command to install GIT in your system.

Step 2: To check the git version you can use the below command:

git –version

GIT Configuration

Step 3: Before using GIT repository we have to configure the “email id” and the “username”. Thus use the following commands to configure.

git config --global user.name  “Your Name”
git config --global user.email  your email address

As you have configured the “user name” and “email id”, all the above information is stored in the below gitconfig file

~/.gitconfig

Git Basic Commands

Step 4: Create and Initialize a GIT repository using the below commands.

mkdir -p /home/acadgild/myproject
cd /home/acadgild/myproject/
git init

Step 5: Add and Commit files to GIT repository by using the below commands.

vim wordcount.py
git add .
git commit -m "First Commit"

You have successfully installed and configured the GIT. Now you are ready to use this open-source distributed version control system.

Ajit Khutal

Ajit Khutal has been working with AcadGild as an Associate Big Data analyst with expertise in Big Data Technologies like Hadoop, Spark, Kafka, Nifi. He has been a Python enthusiast and been associated with the implementation of many Analytics project related to various domains like E-commerce, Banking, and Education.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Articles

Close
Close