GIT Cheat Sheet
The Git cheat sheet presented in this DevOps tutorial is designed for those who have an interest in learning file management using Git as a tool. This cheat sheet will be a handy reference not only when you learn Git but when you start working with it too. Don’t worry if you are a beginner and have no idea about how Git works. Intellipaat’s Git cheat sheet will give you a quick reference to the basics that you must know.

What is Git?
Git is a DevOps tool that is used as a version-control system for tracking the changes happening in system files and coordinating the work on those files among a group of people. In the software development field, Git is used in source code management and for tracking the changes made in any file.
- Git is a distributed version control and source code management system with an emphasis on speed.
- It is a repository used to manage projects, the set of files, as they change over time.
- Using Git, every code change or commit we make gets updated in the development code of a project.
Watch this Git Tutorial for Beginners video:
Process Flow
It shows the process flow with components used to perform certain tasks:
- Plan: It can be created or deleted by itself based on the updates in the source repository.
- Code: It is the statement written to perform a task in a repository.
- Shared repository: It is the repository that is shared among several members in order to perform a task.
- Continuous integration: It helps in updating a repository with the changes made in the code and provides integration with the changes, time to time.
- Build: It is used to manually build products and dependencies to Git.
- Configuration management: It is a process of tracking and controlling the changes made in a system.
- Deploy: Deploy is the process of pushing the code to a remote server.

Be ready for the industry by going through these Top DevOps Interview Questions and Answers!
Version Control
Version control is the management of changes made to the code, documents, programs, large sites, and other information. The changes are termed as versions.
A version control system (VCS) is used to perform the following:
- It allows developers to work simultaneously.
- VCS does not allow overwriting each other’s changes.
- It maintains a history of every version.
There are two types of version control systems:
- Centralized VCS
- Distributed VCS
Our DevOps tool, Git falls under the category of distributed VCS.
Life Cycle

Become a master of DevOps by enrolling in this online DevOps Training in London!
Get 100% Hike!
Master Most in Demand Skills Now !
Git and GitHub
Git is a VCS that supports distributed nonlinear workflows by providing data assurance for developing quality software.
Its features are as follows:
- Distributed: A distributed development of code
- Compatible: Works with existing systems and protocols
- Non-linear: Allows the non-linear development of code
- Branching: Easy to create and merge branches
- Lightweight: Lossless compression
- Speed: Faster than the remote repository
- Open-source: A free tool and hence economical
- Reliable: Not viable to any loss of data upon crashes
- Secure: Uses SHA1 and checksum
For more information, visit the Git vs Github blog by Intellipaat.
Git Operations and Commands
Git Configuration
- For the initial configuration of username, email, and code highlighting (optional):
$git config -- global user.name”firstname lastname”
$git config -- global user.email” [email protected]”
$git config -- global color.ui true (enables code highlights)
$git config --list
Initializing Git
$git init
$git status
Adding and Removing Files
$git add<filename>
$git add<filename> <2nd filename> <3rd filename>
- To add all the updated files:
$git add --all ( use -A instead of -all too )
$git rm -r <filename>
Committing Changes
- To pass a message, use ‘commit’ with ‘-m’:
$git commit -m “body_of_message”
- To amend the last commit or the last message:
$git commit --amend -m “new_message”
Learn DevOps from Intellipaat’s DevOps Training in Sydney to boost your career!
Pushing and Pulling
Here, a remote repository typically represents a remote server or a Git server.
- To create a remote repository via GitHub, go to:
https://github.com/YourUsername/appname.git
$git remote add origin<link>
$git push -u origin master
$git clone <clone>
Branching and Merging
Following are the branching and merging commands for GIT :
Command |
Description |
git branch |
To list branches |
git branch -a |
To list all the branches |
git branch [branch name] |
To create a new branch |
git branch -d [branch name] |
To delete a branch |
git push origin –delete [branchName] |
To delete a remote branch |
git checkout -b [branch name] |
To create a new branch and switch to it |
git checkout -b [branch name] origin/[branch name] |
To clone a remote branch and switch to it |
git checkout [branch name] |
To switch to a branch |
git checkout – |
To switch to the branch last checked out |
git checkout — [file-name.txt] |
To discard the changes made to a file |
git merge [branch name] |
To merge a branch into an active branch |
git stash |
To stash the changes in a dirty working directory |
git stash clear |
To remove all the stashed entries |
Learn more about the basic commands in this Git Tutorial by Intellipaat.
Sharing and Updating Projects
Command |
Description |
git push origin [branch name] |
To push a branch to a remote repository |
git push -u origin [branch name] |
To push the changes made to a remote repository (-u remembers the branch for the next use) |
git push origin –delete [branch name] |
To delete a remote branch |
git pull |
To update a local repository to the newest commit |
git pull origin [branch name] |
To pull the changes from a remote repository |
git remote add origin ssh://[email protected]/[username]/[repository-name].git |
To add a remote repository |
git remote set-url origin ssh://[email protected]/[username]/[repository-name].git |
To set a repository’s origin branch to SSH |
Interested in grabbing an industry-recognized DevOps certification? Intellipaat’s DevOps Course in Bangalore is just designed for you!

Inspection and Comparison
Command |
Description |
git log |
To view the changes made |
View changes |
To view changes (in detail) |
git diff [source branch] [target branch} |
To preview changes before merging |
Intellipaat’s comprehensive DevOps Training would help you be a certified DevOps Engineer!