Git version control (latest 2.28.0) how to

ComputerCarriage > Posts > Commands > Git version control (latest 2.28.0) how to
git version control

Introduction to Git version control

In general the version control is used to preserve the changes made in a software codes, documents and other formats. For example if a group people are accessing the documents like release notes or instructions, if someone edits, so that we can find what he has changed from the previous versions, so that we can able to restore the changes made and back to original. we have the history of documents that are stored in version controlled.

There are lot version control softwares are available such as Clearcase, SVN, share-point, git etc. each software having lot of add-ons features on top of the version control.

Git Installation

Before installing git version control or any software update the latest packages and security updates

For rpm based packages

dnf update -y


yum update -y

For Debian based packages

apt update
apt upgrade

Download the Git

There are multiple ways of installing the git, download using the software repositories, or using binary or source codes

Download page:

Install Git in CentOS 8

To install rpm based installer use dnf or yum using the repository

dnf install git-all -y

Install git in Debian/ Ubuntu

To install Debian based packages use apt

apt-get install git

For Ubuntu, this PPA provides the latest stable upstream Git version

add-apt-repository ppa:git-core/ppa # apt update; apt install git

Install in openSUSE

zypper install git


pkg install git

Solaris 9/10/11 (OpenCSW)

pkgutil -i git


pkg_add git

Source code downloads and Other formats

Also we can download the latest tar ball and install it

Download for Windows

Git supports both 32-bit and 64-bit setup packages, also available on portable installer

Download for Mac

If we installed already git, download the latest version

git clone

git GUI clients

Git is compatible GUI tools which are useful for those who wants easy operations, also there are free and paid GUI clients are available, you can visit for more information

Few git clients that are useful are listed below,

Source TreeSupports Mac, Windows
Github DesktopSupports Mac, Windows
TortoiseGitSupports Windows
Git ExtensionsSupports Windows,Linux and Mac
GUI clients for git

Git basics commands

In this section we are going to see basic commands like how to initialize the git and store the files in the git, Check the version using the below command

Note: We have tested in CentOS 8

[root@server1 ~]# git --version
git version 2.18.4

git init

To initialize the git use init command.

[devops@server1 scripts]$ git init
Initialized empty Git repository in /home/devops/scripts/.git/

Create config parameters

[devops@server1 scripts]$ git config --global "Bala Subramanian"
[devops@server1 scripts]$ git config --global ""
[devops@server1 scripts]$ git config --list Subramanian

Now you will find a directory is created in the current directory

devops@server1 scripts]$ ls -la
total 0
drwxrwxr-x 3 devops devops 18 Sep 16 05:10 .
drwx------. 5 devops devops 162 Sep 16 05:10 ..
drwxrwxr-x 7 devops devops 119 Sep 16 05:10 .git
[devops@server1 scripts]$

Create a file and the file to git repo

For example, we are creating a file called with the below contents

[devops@server1 scripts]$ cat
echo "Enter the name:"

Add the file to the git repo

[devops@server1 scripts]$ git add

If we check the status it will show of the new file is created but yet to commit the changes

[devops@server1 scripts]$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached …" to unstage)
new file:
[devops@server1 scripts]$

Commit the changes

Commit the changes made to the file

[devops@server1 script]$ git commit -m "added file"
[master (root-commit) a61a9e2] added file
1 file changed, 2 insertions(+)
create mode 100644

If we check the status now we will find there it is up to date

[devops@server1 script]$ git status
On branch master
nothing to commit, working tree clean
[devops@server1 script]$

Git log

We can check the changes made using the git log comamnd

[devops@server1 script]$ git log
commit a61a9e2bc435c2c4d4d7b3e4600f47e7432d8407 (HEAD -> master)
Author: Balasubramanian
Date: Wed Sep 16 05:19:36 2020 -0400
added file
[devops@server1 script]$

Now add few more contents in the file, execute git diff command,

[devops@server1 scripts]$ cat
echo "Enter the name:"
read NAME
echo "This is $NAME"
[devops@server1 script]$ git diff
diff --git a/ b/
index cc91e81..0952908 100644
--- a/
+++ b/
@@ -1,2 +1,4 @@
echo "Enter the name:"
+read NAME
+echo "This is $NAME"

In the below example it will show what i have changed from the previous commit

Check the git status, it will show the modified file and next command to execute like add / commit a file

[devops@server1 script]$ git status
On branch master
Changes not staged for commit:
(use "git add …" to update what will be committed)
(use "git checkout -- …" to discard changes in working directory)
no changes added to commit (use "git add" and/or "git commit -a")
[devops@server1 script]$

Execute git add to update the contents of the file

[devops@server1 script]$ git add -A
[devops@server1 script]$ git status
On branch master
Changes to be committed:
(use "git reset HEAD …" to unstage)

Now you will see the file has been added, commit the file with the change notes

[devops@server1 script]$ git commit -m "Added few lines in script"
[master ed29977] Added few lines in script
1 file changed, 2 insertions(+)
[devops@server1 script]$ git status
On branch master
nothing to commit, working tree clean
[devops@server1 script]$

Hope you had a basic idea of about git and how to install and use it. we will work on more topics on git in the future posts on git version control

Also check how to use yum and dnf for installing git version control

dnf –

yum –

Leave a Reply

%d bloggers like this: