Menu Close

Git Commands Tutorial


In this tutorial, we will see the most important daily usage of git commands. Every developer should know about this. It’s really helpful when you are working on a team project. The list of git commands are.

List of Git Commands (commonly used)

Git Clone

Git Clone command is used to download the project from a remote server. Otherwise you can also download the project by visiting GitHub’s website.

git clone your-repostory-link 

Git Branch

Git Branch command is used for more developers and programmers can work one project at a time. Follow the below git commands to create or delete the branches of your project.

Creating a new branch:

git branch 

This command creates the new branch locally

git push -u 

This command is used to push the new branch into the remote repository.

Viewing branches:

git branch or git branch --list 

Deleting a branch:

git branch -d 

Git Checkout

The Git Checkout command is used to switch one branch to another branch and also we can use it for checking out files and commits.

git checkout branchname 

The below command is used to create a new branch and switch to it at the same time.

git checkout -b branchname 

Git Status

Git Status displays the working state of the current branch like commits, files created, modifications etc..

git status 

Git Add

Git Add command is used to move files from the working directory to the staging area and it does not affect the repository in any other way until we run the git commit.

To add a single file:

git add 

To add everything at once:

git add -A 

Git Commit

The Git Commit command is very useful for developers. We can write short messages of what modifications we have done to the project. So this message helps to understand the source code long after if needed.

git commit -m "commit message 

Git Push

Git Push command is used to upload your new branch or local contents to a remote repository.

git push 

Git Pull

Git Pull command is used to download a branch from a repository, then it merges into the current branch.

git pull 

Git Revert

Git Revert command reverts the last changes of the source code. It helps to undo your changes instead of deleting the commit history.

git revert 

Git Merge

Git Merge command is used to merge the one branch to the another branch.

git merge 

Git Remote

Git Remote command is used to create new remote connections on popular services like GitHub, Bitbucket and Gitlab.

git remote 

Git Fetch

Git Fetch command fetches required files from the remote repository to the local repository.

git fetch 
Posted in Git