8 Git Commands You Should Know

Sagar Rao
2 min readApr 1, 2022

--

Photo by Praveen Thirumurugan on Unsplash

Git is a powerful version control system for tracking changes in files and coordinating work on projects with others. These 8 commands will get you up and running with Git.

1. git init

The git init command creates a new Git repository in the current directory.

2. git add

The git add command adds files to the staging area. The staging area is like a buffer between your working directory and your Git repository. Files in the staging area are not committed to Git yet, but they will be when you run the git commit command.

3. git commit

The git commit command commits the files in the staging area to the Git repository. This creates a new Git commit object with a message about what was changed.

4. git status

The git status command shows the status of the current Git repository. This includes the files that have been added, the files that have been changed, and the files that have been staged for the next commit.

5. git diff

The git diff command shows the differences between the files in the staging area and the files in the Git repository.

6. git checkout

The git checkout command checks out a new working copy of the files in the Git repository. This overwrites the files in the working directory with the files from the Git repository.

7. git merge

The git merge command merges the changes from one branch into another branch. This creates a new commit object that contains the changes from both branches.

8. git branch

The git branch command creates and deletes branches in a Git repository. Branches are a way to isolate changes in a Git repository so they can be tested and merged into the main branch.

--

--