Juhi Vishwakarma
By Juhi Vishwakarma

Most Used Commands of Git

Most Used Commands of Git

Git commands Cheat Sheet

to check your Git configuration:

1
2
3
git config -l

to setup your Git username:

1
2
3
git config --global user.name "name"

to setup your Git user email:

1
2
3
git config --global user.email "signups@fabiopacifici.com"

to cache your login credentials in Git:

1
2
3
git config --global credential.helper cache

to initialize a Git repo:

1
2
3
git init

to add a file to the staging area in Git:

1
2
3
git add filename_here

to add all files in the staging area in Git:

1
2
3
git add .

to add only certain files to the staging area in Git:

1
2
3
git add fil*

to check a repository’s status in Git:

1
2
3
git status

to commit changes in the editor in Git:

1
2
3
git commit

to commit changes with a message in Git:

1
2
3
git commit -m "your commit message here"

to commit changes (and skip the staging area) in Git:

1
2
3
git commit -a -m"your commit message here"

to see your commit history in Git:

1
2
3
git log

to see your commit history including changes in Git:

1
2
3
git log -p

to see a specific commit in Git:

1
2
3
git show commit-id

to see log stats in Git:

1
2
3
git log --stat

to rename files in Git:

1
2
3
git mv oldfile newfile

to revert staged changes in Git:

1
2
3
4
5
git reset HEAD filename

git reset HEAD -p

to create a new branch in Git:

1
2
3
git branch branch_name

to switch to a newly created branch in Git:

1
2
3
git checkout branch_name

to list branches in Git:

1
2
3
git branch

to create a branch in Git and switch to it immediately:

1
2
3
git checkout -b branch_name

to delete a branch in Git:

1
2
3
git branch -d branch_name

to merge two branches in Git:

1
2
3
git merge branch_name

to add a remote repository in Git:

1
2
3
git add remote https://repo_here

to see remote URLs in Git:

1
2
3
git remote -v

to push changes to a remote repo in Git:

1
2
3
git push

to pull changes from a remote repo in Git:

1
2
3
git pull

to merge a remote repo with your local repo in Git:

1
2
3
git merge origin/main