Install Git on CentOS 7.5

Git is a very popular Version Control System (VCS). It is written by the creator of Linux Kernel, Linus Torvalds. It is used to manage versions and snapshots of source codes of different software. It is used by software developers and software companies all around the world.

Git is a collaborative tool that helps many people work on the same project simultaneously. Git has a remote or central repository. This is where everyone pushes their changes. A developer clones a snapshot of the remote Git repository. It keeps a local copy of the remote repository in the developer’s computer. The developer makes changes to the source code and then he can push the changes back to a remote Git repository. The codes then can be checked and merged by the maintainer of that repository. This is how Git works.

In this article, I will show you how to install Git on CentOS 7.5 and the basics of Git. Let’s get started.

Installing Git

Git is available in the official package repository of CentOS 7.5.

First update the yum package repository cache with the following command:

$ sudo yum makecache

The yum package repository cache should be updated.

Now install Git with the following command:

$ sudo yum install git

Press y and then press <Enter> to continue.

Git should be installed.

You can check whether Git is working with the following command:

$ git –version

As you can see, Git is installed and working correctly.

Now let’s see how to use Git.

Initial Configuration of Git

Before you can use Git, you have to set some global Git variables, such as your name, email etc. You do not need to repeat these commands every time. This is a onetime configuration.

First set your full name with the following command:

$ git config –global ‘YOUR FULL NAME’

$ git config –global ‘YOUR EMAIL’

Enabling Colors in Git

By default, on CentOS 7.5, colors are disabled in Git. But colors make Git easier to use. Don’t worry, you can enable colors easily.

Run the following commands to enable colors in Git:

$ git config –global color.branch auto
$ git config –global color.diff auto
$ git config –global color.status auto
$ git config –global color.ui auto

Colors should be enabled in Git.

Initializing a Git Repository

To get a project or directory for Git ready, first you have to initialize it.

First navigate into your project directory with the following command:


Now run the following command to initialize the directory for Git:

$ git init

The directory should be initialized as you can see from the screenshot below.

Tracking Files in a Git Repository

In a Git repository, you first tell Git what files or directories to track for changes. This is also called adding files or directories to the Git repository.

You can check the status of your Git repository with the following command:

$ git status

As you can see, I have one untracked file index.php

You can add index.php file to the Git repository as follows:

$ git add index.php

Now git status says index.php is ready to commit.

You can add all the files and directories in your newly created Git repository as follows:

$ git add -A

Committing Changes to the Repository

Whenever you make any changes to a file in your Git repository, you must add it to your Git repository with git add command as I showed you earlier. Then you have to commit the changes to the repository as follows:


Checking All the Commits

You can check all the commits you’ve made with the following command:

$ git log
$ git log –oneline

As you can see, my previous commit is listed.

Cloning a Git Repository

You can also clone an existing Git repository from GitHub or BitBucket. Just grab the Git repository URL and run the following command:


The Git repository should be cloned.

A new directory should be created in the directory where you ran the command from as you can see:

If you navigate to the directory and check you should see all the commits of that Git repository:

That’s how you install and use Git on CentOS 7.5. Thanks for reading this article.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Git Bisect Tutorial

Commenting your commits is an essential part of maintaining traceable code. It helps you track problems. However, finding...

Interfacing with GitHub API using Python 3

GitHub as a web application is a huge and complex entity. Think about all the repositories, users, branches, commits, comments,...

Install SmartGit Git Client on Ubuntu, Linux Mint, CentOS, Fedora, RHEL

SmartGit is an efficient Git Client user interface with support for GitHub, Pull Requests + Comments, SVN as well as Mercurial....
Bài Viết

Bài Viết Mới Cập Nhật

Mua Proxy V6 Nuôi Facebook Spam Hiệu Quả Tại Onetcomvn

Hướng dẫn cách sử dụng ProxyDroid để duyệt web ẩn danh

Mua proxy Onet uy tín tại

Thuê mua IPv4 giá rẻ, tốc độ nhanh, uy tín #1

Thuê địa chỉ IPv4 IPv6 trọn gói ở đâu chất lượng, giá RẺ nhất?