Skip to content

Git Basics & Cheat Sheet



Git is a popular version control system used by developers all over the world. It is a powerful tool that allows developers to track changes to their code and collaborate with others. However, with so many commands and options, it can be overwhelming. That’s why many developers use a Git cheat sheet to help them remember the most common commands and their syntax.

What is Git?

Git is a distributed version control system that has transformed the way developers work on projects. Unlike older, centralized version control systems, Git provides every developer with a complete copy of the entire project history. This approach enables more flexible workflows and safer project management. Its decentralization makes it incredibly powerful for collaborative software development.

Why Should You Learn Git?

  • History Tracking: Git records every change made to your project, allowing you to revert to previous versions whenever necessary.
  • Branching and Merging: With Git, you can create separate branches for new features. This makes it easy to experiment with ideas without affecting the main project.
  • Staging Area: Git lets you decide exactly which changes to include in your next commit, offering precise control over your project’s history.
  • Collaboration: Git simplifies collaboration by making it easy to pull others’ changes into your project and push your changes to them.

Installing Git

To begin, you need to install Git:

  • Windows: Download and execute the Git installer from Git’s official website.
  • Mac: If you have Homebrew installed, simply enter brew install git in the terminal. If not, download the installer from the Git website.
  • Linux: Use your distribution’s package manager. For Debian-based systems, enter sudo apt install git. For Fedora, enter sudo yum install git.

Configuring Git

After installation, set up your identity:

git config --global "Your Name"
git config --global ""

These configurations are important as they are included in your commits, identifying you as the author.

Creating Your First Git Repository

To start your project, create a new repository:

mkdir my-first-git-project
cd my-first-git-project
git init

This command sequence creates a new directory and initializes it as a Git repository.


Basic Commands

The following are some of the most basic Git commands that every developer should know:

  • git init: Initializes a new Git repository.
  • git add: Adds changes to the staging area.
  • git commit: Commits changes to the repository.
  • git status: Shows the status of the repository.
  • git log: Shows the commit history.

Branching and Merging

One of the most powerful features of Git is its branching and merging capabilities. The following are some of the most important commands for branching and merging:

  • git branch: Lists all branches in the repository.
  • git checkout: Switches to a different branch or commit.
  • git merge: Merges changes from one branch into another.

Collaboration and Remote Repositories

Git is designed for collaboration, and it’s important to know how to work with remote repositories. The following are some of the most important commands for collaboration and remote repositories:

  • git clone: Copies a repository from a remote server.
  • git pull: Downloads changes from a remote repository.
  • git push: Uploads changes to a remote repository.
  • git remote: Lists all remote repositories.




  • gitlab version(
  • github version(