Git Tutorial – Install & Setup Git on Linux and Windows

A version control system (VCS) which tracks the history of changes as teams collaborate on a project together. Git is a distributed version control system (DVCS) commonly used for open source and commercial software development. Git was initially designed and developed by Linus Torvalds. Here in this tutorial, you will learn how to install and setup Git.

Installing Git

First, you should check if you have Git command line tools installed on your machine.A few operating systems also come with Git installed, so it is worth checking before you install.

$  git --version

if Git is not installed, you will get an error as following:

-bash: git: command not found
'git' is not recognized as an internal or external command, operable program or batch file.

So you have to install Git into your machine. Let’s go for Git installation into several of the major operating systems.

Installing Git on Linux

It is very to install Git by using your version of Linux’s default repositories. So Let’s go through how to install Git on your local Linux machine using default repos.

Installing Git on Ubuntu 18.04/20.04 or Debian 10

You can use apt package management tools to update your local repositories. Afterwards, you can install Git as follows:

$  sudo apt update
$  sudo apt install git

Since this is the fastest method of installing Git but version may be older than the latest version. If you need the latest release, consider Compiling Git from Source by using this tutorial.

Installing Git on CentOS

By using yum (native package manager),you can search and install the latest Git package available in CentOS’s default repositories. First make sure yum is up to date by following command and then install Git package.

$  sudo yum -y update
$  sudo yum install git

As we said earlier this is the easiest method to install Git, If you want to install the Git from source code then follow this tutorial.

Installing Git on Fedora

For Fedora, Git packages are available for both yum and dnf. DNF (Dandified Yum) has been default package manager for Fedora since Fedora 22.

$  sudo dnf update
$  sudo dnf install git

Installing Git on Windows

There is an open-source project called Git for Windows, which is separate from the official Git website. This tool provides both command line and graphical user interface tools for using Git on your Windows machine. To install Git on your windows machine please follow these steps.

Setting Up Git

As you have Git installed in your machine, now you need to follow few things to setting up Git.The easiest way of doing this is using the git config command. Specifically, we need to provide your name and email address because Git writes this information into each commit you do.

You can do this by following commands:

$  git config --global user.name "Your Name"
$  git config --global user.email "[email protected]"

You can verify all of the configuration items that you have set by following:

$  git config --list

#outut

user.name=Your Name
[email protected]

There is another method to check the configuration. There is .gitconfig (a hidden config file) that contains all this config information.

$  vi ~/.gitconfig

#output

[user]
name = Your Name
email = [email protected]

Once you’re done making changes in this file, you can exit vi by typing the :wq .

Conclusion

As you installed and set up Git on your local machine, now you are able to use Git for version control of your own software projects as well as contribute to open-source projects that are open to the public.

See Also : An Overview of Git – Core Concepts of Distributed Version Control System

 

Share on:

Ravindra Kumar

Hi, This is Ravindra. I am founder of TheCodeCloud. I am AWS Certified Solutions Architect Associate & Certified in Oracle Cloud as well. I am DevOps and Data Science Enthusiast.

Recommended Reading..

2 thoughts on “Git Tutorial – Install & Setup Git on Linux and Windows”

Leave a Comment