Git Command - best cheat sheet
Posted by Vaibhav Singh
Posted on 1st Mar 2026 1:47 AM
( 30 min Read & 40 min Implementation )

#git # cheatsheet #interviewquestion #versioncontrol #techelliptica
Article Outline

Git is widely recognized as the leading distributed version control system across organizations today, and for good reason. The features and benefits Git brings to development workflows are invaluable, enhancing productivity and significantly saving time.


Git Repositories Structure


Before diving into essential Git commands, itโ€™s important to understand the underlying structure of Git as a distributed system. Git creates different types of repositories, each serving a distinct purpose in the workflow and enabling efficient collaboration. This structure forms the backbone of Gitโ€™s version control capabilities, making it an invaluable tool in modern development environments.


Remote Repository: This is a centralized version of the repository hosted on a server, enabling collaboration among multiple contributors. It serves as the authoritative source of truth, where updates are pushed to or pulled from by team members working on the project.

Eg. When we create repository on github server. Its a centralized repository and consider as remote repository because anyone can view, copy and perform various action worldwide.


Local Repository: This is the developerโ€™s local copy of the repository, stored on their machine. It includes the full project history and allows for commits and modifications that are isolated from the remote repository until they are pushed. This local copy empowers developers to work offline and experiment freely.

Note: Itโ€™s important to clarify that the project repository in an IDE like IntelliJ, Eclipse, or any other environment is not the same as Git's local repository. While an IDE project repository is often visible and specific to that IDEโ€™s workspace, the local repository in Git is stored in a hidden .git directory on your local machine. This local repository maintains the entire history of the project and allows for commits across different workspaces or IDEs on the same machine.

This means that you can work in multiple workspaces, or switch between different IDEs on the same machine, while Gitโ€™s local repository consistently tracks and saves all committed changes, providing a unified and efficient way to manage your projectโ€™s versions.



Staging Area (Stage Repository): The staging area is an intermediate zone where changes are added before committing them to the local repository. It allows developers to group and review specific changes for a clear, organized commit history, ensuring only finalized code is committed.


Working Directory (Working Repository): The working directory (or working repository) is where developers actively create and edit files. This directory reflects the current state of the project and serves as the primary environment for ongoing development. Not all files in the working directory need to be tracked by Git, however. Only the files added to tracking will move to the staging area for inclusion in the next commit.


If a file remains untracked, it will not be added to the staging area, and therefore, it wonโ€™t be part of Gitโ€™s version history. This selective tracking provides flexibility, allowing developers to exclude temporary, personal, or development-specific files from version control until theyโ€™re ready for inclusion. This approach keeps the repository clean and focused on meaningful changes.



Git Important Commands


Letโ€™s take a closer look at the foundational commands that allow developers to leverage the full power of Git.


git clone

git clone we use when we need to copy remote repository to working repository (usually our local machine) "We can do specific folder, specific tag and specific commit clone (called shallow clone) too "


git add

git add, we use when we need to index our files in working area. Well until we will not index our files, it will be non-tracked files. so to make file from non-tracked to tracked, we need to add file in index, which is usually move to staging area.

"We can do specific folder, specific file and all files in all directory too"


git reset (opposite to add)

If any one our file is tracked mode , and we want bring back that file into non-tracked mode, then we use git reset

"usually we can reset file and commit both"


git commit

git commit migrate file from staging area to local repository. with git commit we always have to provide message. reverting the commit we can do through reset too.

"usually after git commit, our current branch move 1 commit ahead from remote branch"


git push

git push migrate file from local repository to remote repository. after git push command all committed files will be visible in remote repository


git fetch

git fetch bring copy from remote repository to local repository. (git doesn't update these file in working repository in git fetch)


git merge

git merge bring updated files from local repository to working repository


git pull

git fetch + git merge


Related Articles
Date, DateFormat and Calendar Class in Java

Encapsulation in Java

Arrow Function in Javascript

From Manual to Intelligent Automation: How Modern QA is Evolving with AI & Playwright

Capturing Videos & Screenshots in Playwright: A Complete Guide

Fixtures In Playwright - A Short Discussion

Promise in Javascript - A Comprehensive Guide

Callback function in JavaScript

How to Connect Python with MySQL

Stop Writing Syntax: Welcome to the Era of AI-Driven Development (AIDD)

Handling HTML5 Native Validation Messages in Playwright

Python - Constant is a myth. We all are adults here

Understanding Python Collection Symbols: A Simple Memory Technique

Decorator in Python

Meet the Computer 13,000ร— Faster Than Todayโ€™s Machines โ€” Googleโ€™s Willow Chip Runs OTOC Quantum Echoes

Test Report Metrics - Real Face of QA Process

๐—ฆ๐—ฒ๐˜๐˜‚๐—ฝ ๐—š๐—ผ๐—ผ๐—ด๐—น๐—ฒ ๐—–๐—น๐—ผ๐˜‚๐—ฑ ๐—–๐—ฟ๐—ฒ๐—ฑ๐—ฒ๐—ป๐˜๐—ถ๐—ฎ๐—น๐˜€ ๐—ข๐—”๐˜‚๐˜๐—ต ๐Ÿฎ.๐Ÿฌ ๐—ถ๐—ป ๐—ผ๐—ฟ๐—ฑ๐—ฒ๐—ฟ ๐˜๐—ผ ๐—ฎ๐—ฐ๐—ฐ๐—ฒ๐˜€๐˜€ ๐—š๐—ผ๐—ผ๐—ด๐—น๐—ฒ ๐—ฆ๐—ต๐—ฒ๐—ฒ๐˜๐˜€ ๐—”๐—ฃ๐—œ๐˜€

A Step-by-Step Guide to Creating Service Accounts in Google APIs

Read Data From Google-Sheet

@DataProvider and @Factory Annotation in TestNG

All Comments ()
Do You want to add Comment in this Blog? Please Login ?