DEV Community

Mohit Kala
Mohit Kala

Posted on

Useful Git commands for common tasks

1)Git Clone

Git Clone Is A Command For Downloading Existing Source Code From A Git Repository (Like Azure DevOps, GitHub)

git clone “repository url” -b “branch name”

2) Git Branch

Branches Are Highly Important In The Git World. By Using It, Developers Are Able To Work In Parallel On The Same Project.

i) Creating A New Branch:
git branch “branch-name”

ii) To Push The New Branch
git push -u “remote” “branch-name”

iii) Viewing Branches:
git branch or git branch — list

iv) Deleting Branch
git branch -d “branch name”

3) Git Commit

Most-Used Command Of Git. Once We Reach A Certain Point In Development, We Want To Save Our Changes (Maybe After A Specific Task Or Issue).
git commit -m “commit message”

4) Git Push

After Committing Your Changes, The Next Thing You Want To Do Is Send Your Changes To The Remote Server. Git Push Uploads Your Commits To The Remote Repository.
git push “remote” “branch-name”

5) Git Status
The Git Status Command Gives Us All The Necessary Information About The Current Branch.
git status

6) Git Diff

You can use this command to see the unstaged changes on the current branch.

git diff — staged

7) Git Add

This is the command you need to use to stage changed files. You can stage individual files

git add “file path”

for all files
**
git add**

Top comments (0)