DEV Community

Cover image for Git Cheatsheet that will make you a master in Git
hichamelhirch
hichamelhirch

Posted on

Git Cheatsheet that will make you a master in Git

Introduction to Git

Git is an essential version control system that enables developers to track changes and collaborate effectively on projects. It has become a crucial tool for managing code, whether you're working alone or with a team. However, learning Git can be daunting, especially for beginners unfamiliar with its commands and functionality. In this Git cheatsheet, we’ll explore key commands every developer should know, from setting up a repository to advanced tasks like branching and merging. This guide is designed to help both newcomers and seasoned developers enhance their Git skills and streamline their workflow, making Git easier and more efficient to use.

Basic Git commands

Initialization

To initialize a new Git repository in the current directory, run the following command:

Image description

This creates a hidden .git directory in the current directory that tracks changes to your code.


Cloning

To clone an existing Git repository to your local machine, run the following command:

Image description

This creates a new directory on your computer with a copy of the repository.


Staging changes

Before you commit changes to your code, you need to stage them using the git add command. This tells Git which changes you want to include in your commit.

To stage a file or directory, run the following command:

Image description

You can also stage all changes in the current directory by running:

Image description

Top comments (0)