Introduction
In this article, we will see what are the list of commonly used commands in Git. These are the commands which are really useful while working on any project. Hope this will be useful.
1) To initialize GitHub Repository in your local machine project folder:
git init
2) To get the status of files:
git status
3) To configure Username and Password:
git config –global user.name “user-name”
git config –global user.email “email-id”
4) To clone the repository to your local machine:
git clone URL
Note: Here URL is GitHub Repository URL
5) To add a single file to GitHub:
git add file-name
6) To add all the modified file to GitHub:
git add .
git add -A
7) To commit the changes to GitHub:
git commit -m “commit-message”
8) Get the latest code from the main branch:
git pull
9) To pull the latest code from a particular branch:
git pull branch-name
10) To list all the branches including local and remote:
git branch -a
11) To create a new branch name:
git branch branch-name
12) To delete a branch:
git branch -d branch-name
13) Delete remote branch:
git push origin --delete branch-name
14) To create a new branch and switch to the new branch created:
git checkout -b branch-name
15) Rename branch (local):
git branch -m old-branch-name new-branch-name
16) To switch a branch:
git checkout branch-name
17) To discard changes of a particular file:
git checkout -- file-name.txt
18) Merging branch (active branch):
git merge branch-name
19) Merging to a target branch:
git merge source-branch target-branch
20) Stash your changes:
git stash
21) Remove stash:
git stash clear
22) Show difference:
git diff source-branch target-branch
23) To view the log/changes:

Venkatasubbarao PolisettyPosted Jul 28, 2021, 6:46 AM
Useful Article!
Aryan KumarPosted Jul 4, 2021, 2:58 AM
Great Work....
Gurpreet AroraPosted Jun 30, 2021, 2:02 PM
Nice article
Virender ThakurPosted Jun 29, 2021, 9:15 AM
Thank you so much. Really appreciate your efforts.
Mahesh ChandPosted Jun 29, 2021, 4:37 AM
Nicely done! Once again.