Back to Blog
Developer Tools

Git Commands Cheatsheet: The 30 Commands Every Developer Uses Daily

2025-04-15 7 min read

Stop Googling the same Git commands every day. This practical cheatsheet covers the 30 essential commands for committing, branching, merging, and recovering from mistakes.

Most developers use about 10 Git commands 90% of the time. But when things go wrong โ€” merge conflicts, accidental commits, detached HEAD states โ€” you need to know more. Here are the 30 commands every developer should have memorized.

Setup and Configuration

git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git init          # Initialize new repo
git clone URL     # Clone remote repo

Daily Workflow

git status              # See what changed
git add .               # Stage all changes
git add file.js         # Stage specific file
git commit -m "message" # Commit staged changes
git push origin main    # Push to remote
git pull                # Fetch + merge remote changes

Branching

git branch              # List branches
git branch feature-x    # Create branch
git checkout feature-x  # Switch to branch
git checkout -b feature-x  # Create + switch
git merge feature-x     # Merge into current branch
git branch -d feature-x # Delete merged branch

Undoing Things

git restore file.js          # Discard unstaged changes
git restore --staged file.js # Unstage a file
git revert HEAD              # Undo last commit (safe)
git reset --soft HEAD~1      # Undo commit, keep changes staged
git reset --hard HEAD~1      # Undo commit, discard changes (destructive)

Inspection

git log --oneline       # Compact commit history
git diff                # Unstaged changes
git diff --staged       # Staged changes
git blame file.js       # See who wrote each line
git stash               # Temporarily store changes
git stash pop           # Restore stashed changes
git version-control developer cheatsheet

More Articles