DEV Community

sohana khan
sohana khan

Posted on

Git commands I use daily (cheatsheet)

Most Git tutorials throw an encyclopedia at you. But in reality, you’ll use the same ~10 commands every single day.

Here’s my no-fluff daily cheatsheet.

  1. The absolute basics bash git clone # Download a repo git status # What changed? git add . # Stage everything git commit -m "fix: message" # Save changes
  2. Working with remotes bash git pull --rebase # Get latest changes (cleaner history) git push # Upload your commits git fetch # See what changed without merging
  3. Branching (daily) bash git branch # List branches (* = current) git checkout -b feat/x # Create + switch to new branch git switch main # Switch to main (newer syntax) git branch -d old-branch # Delete local branch
  4. Fixing mistakes (no panic) bash git commit --amend -m "new message" # Edit last commit git reset HEAD~1 # Undo last commit (keep changes) git restore file.js # Discard unstaged changes git restore --staged . # Unstage everything
  5. Seeing what happened bash git log --oneline --graph # Pretty commit tree git diff # Unstaged changes git diff --staged # Staged changes
  6. The one "advanced" command I use daily bash git reflog # Show EVERYTHING you did (undo any mistake) Pro tip: Aliases Add these to ~/.gitconfig:

bash
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.st status
git config --global alias.lg "log --oneline --graph"
Now git st, git co main, git lg — saves hours.

Bottom line: You don’t need 50 commands. Master these, and you’re productive.

What’s your most-used Git command? 👇

Top comments (0)