04/09/2025
12 Git Commands Every Developer Should Know! π
Mastering Git is non-negotiable. Hereβs your quick cheat sheet to the essentials!
git init
"Start a new repo."
Turns your current directory into a new Git repository. First step!
git clone
"Download a repo."
Grabs an entire repository from a remote source (like GitHub) and copies it to your local machine.
git add
"Stage your changes."
Prepares a file for committing. Use git add . to stage all changes in the current directory.
git commit -m "message"
"Save a snapshot."
Takes all staged changes and saves them to the project history with a descriptive message.
git status
"See what's up."
Your best friend. Shows which files are modified, staged, or untracked.
git push
"Upload your commits."
Sends your committed changes to a remote repository (like GitHub or GitLab).
git pull
"Download updates."
Fetches the latest changes from the remote repo and merges them into your current branch. (git fetch + git merge).
git branch
"Manage branches."
Lists all branches. Use git branch to create a new one.
git checkout
"Switch branches."
Moves you to a different branch or commit. Use git checkout -b to create and switch in one command.
git merge
"Combine branches."
Merges the specified branchβs history into your current branch.
git log
"View history."
Shows a detailed history of commits for the current branch. Use git log --oneline for a compact view.
git diff
"See changes."
Shows the exact lines of code youβve added or removed before you stage them.
Pro Tip: Use --help with any command to learn more! (e.g., git commit --help)
Which one do you use the most? Did we miss any crucial ones? Let us know in the comments! π