DEV Community

Alexander Omorokunwa
Alexander Omorokunwa

Posted on • Originally published at fossnaija.com on

How To Install And Setup Git In Linux

how to install git banner

What is git?

Git is a distributed code revision software created by Linus Torvalds, (yes the creator of Linux). Git is used in project/source code version control.

That simply means that it ensures that you can save your work (any coding project) at a particular point in time – versions. Each _ save _ is called, in git’s parlance, _ commit _.

You can therefore loadyour project from any commit you’ve have done. In essence you’dbe able to control the “versions” of of your project you want towork with.

One of the advantages ofthis practice (committing code) is that in an event of mishap –either due to a development flaw or mistake, you can simply load aprevious version of your projects instead of starting from thescratch again.

Cool right?

Before you can use all the features of git, you’ll have to install and set it up in your Linux system. So let’s see how we’ll go about this.

Updateyour system

sudo apt-get update
Enter fullscreen mode Exit fullscreen mode

Installgit Software:

sudo apt-get install git
Enter fullscreen mode Exit fullscreen mode

Checkthe version of git you just installed:

git –version
Enter fullscreen mode Exit fullscreen mode

If you got git installedcorrectly you’d get an output similar to:

git version 2.3.2
Enter fullscreen mode Exit fullscreen mode

First TimeConfigurations

Since you’ve gitinstalled, it is now important to set some global variables. Thesevariables are important because it helps git to identify who ismaking changes to a particular code-base.

And it will also helpdevelopers identify you would, maybe in the future, you want tocontribute to other people’s codes. The most common form ofidentification are names (i.e. username) and email. You can set theseconfiguration in git like this:

git config -–global user.name “John”
git config –-global user.email “john-doe@email.com”
Enter fullscreen mode Exit fullscreen mode

Check the all yourconfiguration values;

git config –list
Enter fullscreen mode Exit fullscreen mode

Remember that the mostimportant variables you should be concern about are username andemail, especially at a beginner’s stage. Maybe later when you wantto do intermediary to advanced stuffs you would probably have becomefamiliar with the necessary configuration settings you might need.

When you need help!

To see an overview of thegit sub-commands and syntax you can enter the command on theterminal:

git help
Enter fullscreen mode Exit fullscreen mode

or

git help -a
Enter fullscreen mode Exit fullscreen mode

For git concept guide use:

git help -g
Enter fullscreen mode Exit fullscreen mode

To see what you can dowith the various git command (actions) or concepts you can simply thefollowing format.

git help "command"
git help "concept"
Enter fullscreen mode Exit fullscreen mode

You can use git now onlocal computer to tract you projects/code changes.

You can download a gitcheat-sheet to learn the most important git commands you can workwith.

Happy Linux’NG!

The post How To Install And Setup Git In Linux appeared first on Foss Naija.

Top comments (0)