The most commonly used Git commands.

Ajay Dhangar
2 min readFeb 16, 2023


Git commands

Git is a powerful version control system that allows developers to manage their source code and collaborate with others on software projects. Here are some of the most commonly used Git commands, along with examples of how to use them:

Creating a Repository

git init - Initializes an empty Git repository in the current directory.


dir my_project
$ cd my_project
$ git init

git clone - Clones an existing Git repository from a remote source.


$ git clone

Making Changes

git add - Adds changes to the staging area.


$ git add file1.txt file2.txt

git commit - Commits changes to the repository.


$ git commit -m "Added new feature"

git status - Shows the status of the repository, including any uncommitted changes.


$ git status


git branch - Lists all the branches in the repository.


$ git branch
* master

git checkout - Switches to a different branch.


$ git checkout feature
Switched to branch 'feature'

git merge - Merges changes from one branch into another.


$ git merge feature

git remote - Shows the remote repositories that are currently configured.


$ git remote

git push - Pushes local changes to a remote repository.


$ git push origin master

git pull - Pulls changes from a remote repository and merges them with the local repository.


$ git pull origin master

Viewing History

git log - Shows the commit history of the repository.


$ git log
commit 670b8f7aa07a34237f5c1c02e5ed5e5f37d5ce2b
Author: Ajay Dhangar <>
Date: Wed Feb 16 15:34:06 2023 -0500

Added new feature

commit b2ee1148f2d2e66e0d3e84056b1da3b1a4279f6d
Author: Ajay Dhangar <>
Date: Wed Feb 16 15:20:23 2023 -0500

Fixed bug in login screen

git diff - Shows the differences between the current state of the repository and a previous commit.


$ git diff HEAD~1

These are just a few of the most commonly used Git commands. For a more complete reference, you can refer to the official Git documentation.



Ajay Dhangar

Hello, my name is Ajay Dhangar I’m a web developer with extensive experience for over 4 years. My expertise is to create and website design and more…