Basic git commands

Here is a list of some basic Git commands that will help you get started with git.

Checkout a new branch

git clone git-repo-url
git clone

Create a new local repository

git init

Create a new branch from current working branch and switch to it

git checkout -b <new-branch-name>

Switch to a new branch

git branch <branch-name>

List all available branches

git branch

Check status of files

git status

Add files for commit

git add <file-name>
git add <file-name-1> <file-name-2> <file-name3>
git add *

Remove files for commit

git rm <file-name>


git commit -m "Message for commit"

Pull – Update local repo with latest update from server

git pull

Push – Update changes to repository

git push origin master
#Updates 'master' branch
git push origin <branch-name>
#Updates corresponding branch

Stash – Store changes without commiting

git stash

Stash Apply – Apply stashed changes

git stash apply


git merge <branch-name>
#Merges a different branch into your active branch

View more at :

Leave a Reply

Your email address will not be published. Required fields are marked *