1 min read

Git Cheat Sheet


Git is a distributed version control system that supports collaboration through teams in the corporation. Teams of developers and open-source software maintainers basically handle and manage their projects through Git. It is very useful as open-source software toolkit for developers and DevOps engineers.

Git is ready to download it from the official website and is available for Linux, MacOS and Windows.

Setup Git

Check your Git version with the following command.

git --version

Initialize the current working directory as a Git repository with the following command.

git init

Clone your projects from hosted remotely Git repositories with specified repo's URL or server location on GitHub or GitLab instances.

git clone

Show your current Git directory's remote repository.

git remote


Check the status of your Git repo including files added that are not staged and the files that are staged also.

git status

Include all the available files in the current working directory.

git add .

Remove a file from staging within your working directory.

git reset


Commit the staged files with meaningful commit message that you can track your commits later on.

git commit -m "Added new files"


Show all available current branches with the following command.

git branch

Create a new branch on your working directory.

git branch new-branch

Switch to another existing branch and checkout to your current working directory.

git checkout another-branch

Create the branch and switch to the new one to your current working directory.

git checkout -b new-branch

Merge the specific branch's history into the current one's.

git merge branch-name

Collaborate and Update

Fetch and merge any commits from the tracking remote branch.

git pull

Push your local branch commits to the remote repository branch.

git push origin main


Display the commit history for the currently active branch.

git log
Orestis Pantazos

Orestis Pantazos

DevOps Engineer