Git as a Source Code Management Tool for DevOps – part I

Git is an open / free tool and considered as distributed Version Control System and used extensively for SCM (Software Configuration Management). Along with GIT, we have Gitlab, Bitbucket – they all fall in the same bracket.

GIT Being DVCS (Distributed Version Control System), git is always considered superior than its Counterpart Centralized Version Control System (CVCS) on the part of speed, reliability, scalability. On top of that it is open source tool and freely availability makes it economical without compromising on security aspect.

Git is an integral part of DevOps Pipeline and probably the starting point of DevOps cycle. 


Let us consider the git Architecture consisting of Local and Remote as depicted in Fig-01 .


Git Architecture
Fig-01 Git Architecture

Local Component comprising of following 3 stages

  • Working Directory
  • Staging Area
  • Local Repo

Remote Component is our remote Repo (GitHub/GitLab etc).

Let us try to understand various git operations / commands by grouping them into following groups

  1. Local git
    • Creating git repository
    • Tracking changes
    • Reverting changes
    • Excluding files
  2. Remote git
  3. Branches
  4. Forks

Fig-02 below provides a mindmap view of all the above mentioned git operations groups.

Mindmap view of various git operations
Fig-02 : Mindmap view of various git operations

Now let us explore the git operations and carry out end to end SCM activities.

For the subsequent case study it is assumed that we have installed git already on our Linux machine.

Open a Linux terminal

[gdlr_code title=”To Find the version of git installed” active=”no”]

$ git –version

git version 2.7.4


Find git version
Fig-03 Find git version

[gdlr_heading tag=”h2″ icon=”icon-diamond” font_weight=”bold” ]

git local operations


  • Create git Repo

We’d be cloning an open source project from URL =   using following command

[gdlr_code title=”Clone a project from GitHub ” active=”no”]

$ git clone


Fig-04 : Git Clone a project from GitHub

This will create a clone for the git project from specified URL into stuManager folder.

We change directory to newly cloned project stuManager by running following commands


[gdlr_code title=”list of working directory” active=”no”]

$ cd stuManager/

$ ls -al


Working Directory
Fig-05 : Working Directory

There exists .git folder and its content which we are going to remove by running following command.

[gdlr_code title=”Removing .git folder content” active=”no”]

$ rm -rf .git/


 Removing .git folder and its content
Fig-06 : Removing .git folder and its content

Now we are ready to explore various git operations.

Create git Repo

$ git init

Initialized empty Git repository in /home/devops/zva/stuManager/.git/

Creating a new git repository
Fig-07 : Creating a new git repository


stuManager  folder is our Working Directory.

.git folder is local Repository (or git repository).

$ git status

This command lets us know all the untracked files in our git project.

Viewing git status for untracked files
Fig-08 : Viewing git status for untracked files
  • Excluding files for tracking ( .gitignore)

$ pwd


$ touch .gitignore

$ vim .gitignore

Fig-09 : Excluding files for tracking using .gitignore

After creating this .gitignore file at the project root folder, we again run the below command to check the status of untracked files

$ git status

Fig-10 : git status after excluding files in .gitignore
  • Track Local changes
    • Add files to staging Area


[gdlr_code title=”Add files to staging Area” active=”no”]

$ git add .

$ git status


Add files to staging area
Fig-11 : Add files to staging area

Post adding files to staging area, next step would be to move the changes from staging area to local repo through git commit operation

  • Commit changes to git repo

$ git commit -m “My First Ever Commit”

$ git status

git commit to move changes from staging area to local repo
Fig-12 : git commit to move changes from staging area to local repo
  • View commit history

$ git log

Viewing history by git log
Fig-13 : Viewing history by git log

So summarising the git operations we have explored in this article,

  • Initialised a git repository at Working Directory after cloning a project from GitHub
  • Excluding certain files for tracking with the help of .gitignore
  • Adding files to staging area
  • Committing changes to Local git repo
  • Viewing git status
  • Viewing history of commits by git log

In our next article we would continue to explore for pushing the changes from local repo to remote repo and other important relevant operations. Stay tuned for Part 2 of this series. We will be covering more articles which will cover the entire DevOps lifecycle.

Happy Learning (DevOps) !!!

For upcoming DevOps and related programs please visit the following URL

CP-DOF is the only global certification program which takes a participant through a end to end DevOps lifecycle.



Leave a Comment