14 Git Commands You Should Know As a Beginner

Git plays an important role in the daily workflow of programmers, particularly when collaborating within a team, and it stands as an indispensable tool in the software industry. Having a solid grasp of Git commands is essential for efficient version control and collaboration.

In this post, I will share the top 14 Git commands that every developer should know.

Let’s get started!

1.git init

The git init command is used to initialize a new repository in your project folder.

2.git clone

The git clone command is used to clone an existing git repository onto your local machine. By cloning a repository you can start collaborating on an existing project.

Replace <repository_url> with the URL of the repository which you want to clone.

3.git branch

The git branch command is used to create, list and delete branches.

Creating a new branch:

You can use the following command to create a branch locally.

Replace <new_branch_name> with your new branch name.

Listing branches:

Deleting a branch:

Replace <branch_name> with your branch name.

4.git checkout

The git checkout command is used to switch between branches.

To switch between branches, ensure that any changes in your current branch are either committed or stashed before making the switch. Additionally, make sure the branch you intend to check out already exists locally.

You can use the following command to seamlessly branch creation and switch in one go.

5.git add

The git add command is used to stage changes of a specific file or all changes for the next commit.

For a specific file:

Replace <file_name> with your file name.

For all changes:

6.git reset

The git reset command is used to unstage changes of a file.

Replace <file_name> with your file name.

7.git commit

The git commit command is used to commit staged changes with a descriptive message.

8.git status

The git status command is used to check the status (such as untracked files and changes ready to be committed) of your repository.

9.git log

The git log command is used to display a history of all the commits. It includes commit hashes, authors, dates, and commit messages.

10.git diff

The git diff command is used to check the differences between your current working directory and the last commit.

11.git push

The git push command is used to send your commits to the remote repository. This will only push the committed changes.

If your branch is newly created then you will need to upload the branch with the following command.

12.git pull

The git pull command is used to fetch changes from a remote repository and integrate them into your local branch.

It is essentially a combination of two separate Git commands: git fetch and git merge.

13.git stash

The git stash command is used to temporarily save changes that you’re not ready to commit.

14.git merge

The git merge command combines all branch changes into one branch.

Replace <branch_name> with the branch name whose changes you want to merge into the current branch.

To merge the branches you first need to checkout to the branch in which you want to merge all the branches.


These essential Git commands should be your constant companions on your coding journey. Whether you’re starting a new project, collaborating with a team, or fixing bugs, these commands will guide you through version control, simplifying your development journey and keeping things running smoothly.

Thanks for reading.

For more content like this click here.

Keep coding!

Leave a Comment