DEV Community

Cover image for Git Commands Every Dev MUST know
Mursal Furqan Kumbhar
Mursal Furqan Kumbhar

Posted on

26 5

Git Commands Every Dev MUST know

Hello and Good Morning ☕
I know I had not been writing lately, but now I am back on my writing spree 🎉
Today we are going to see some awesome git commands, that every developer MUST know. Look carefully when I stress on the word MUST. Knowing these commands would definitely make your time easier. 😉
So let's start.

  • Initialize local git repository

git init

  • Add a particular file to a repository

git add git_commands.md

  • Add all uncommitted files to the repository

git add .

  • Set Repository

git config --global user.name 'mursalfk'
git config --global user.email 'mursalfurqan@gmail.com'

  • Add message to your commit

git commit -m "You can add a message to your commit like this"

  • See commit history

git log

  • Add remote Name/URL

git remote add origin 'https://github.com/mursalfk/mursalfk.git'

  • Push your changes to remote repository

git push origin master

  • Clone any repository

git clone 'https://github.com/mursalfk/mursalfk.git'

  • Update the current working directory

git pull origin master

Tired already? Come on... It's not that long 😉
Image description

  • Check difference in between commits

git diff HEAD~1 HEAD

  • Download files from any repository

git fetch origin master

  • Create a new branch

git branch branchName

  • Create a new branch inside a folder

git branch branchFolder/branchName

  • Switch to another branch

git checkout branchName

  • Switch to another branch present in another folder

git checkout branchFolder/branchName

  • Create and checkout to the new branch at the same time

git checkout -b branchName

  • Create and checkout to the new branch present in another folder at the same time

git checkout branchFolder/branchName

  • Merge to a new branch

git merge master

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (3)

Collapse
 
attaullahshafiq10 profile image
Hafiz Muhammad Attaullah

Good lala...

Collapse
 
mahnoor2020 profile image
Mahnoor Naveed

Much Needed 🙌

Collapse
 
nepster23 profile image
Rojil Shrestha

nice one

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay