TK
All writing
Engineering

The 15 Git commands you'll actually use every day

A no-fluff reference for the Git commands that make up 95% of real work — staging, committing, branching, syncing, inspecting history — with the exact command for each everyday task.

Tanveer Khan9 min read

Git has hundreds of commands and flags. You will use about fifteen of them for 95% of your work. This is that fifteen — the 'what's the git command for…' cheat sheet, each one with the situation it's for.

See what's going on

terminal
bash
git status            # what's staged, modified, untracked
git log --oneline     # compact commit history
git diff              # unstaged changes
git diff --staged     # what you're about to commit

Stage and commit

terminal
bash
git add file.ts       # stage one file
git add .             # stage everything (careful — check status first)
git commit -m "feat: add login form"
git commit --amend    # fix the last commit (if not pushed)

Branch and switch

terminal
bash
git branch                    # list branches
git switch -c feature/login   # create AND switch to a new branch
git switch main               # switch to an existing branch
git branch -d feature/login   # delete a merged branch

git switch (newer) is clearer than the overloaded git checkout. Use switch for branches, restore for files — the old checkout did both and confused everyone.

Sync with the remote

terminal
bash
git pull                      # fetch + merge the remote's changes
git pull --rebase             # ...but keep history linear
git push                      # push your commits
git push -u origin feature/x  # first push of a new branch (sets upstream)

Undo the common mistakes

terminal
bash
git restore file.ts           # discard unstaged changes to a file
git restore --staged file.ts  # unstage (keep changes)
git reset --soft HEAD~1        # undo last commit, keep changes staged
git revert <hash>              # safely undo a pushed commit

Stash work in progress

terminal
bash
git stash            # shelve uncommitted changes
git stash pop        # bring them back
git stash list       # see what you've stashed

Set a few aliases and these get faster: git config --global alias.co switch, alias.st status, alias.lg 'log --oneline --graph --decorate'.

Learn these fifteen and you'll rarely need to Google a Git command again. Everything else — cherry-pick, bisect, reflog — you look up the handful of times a year you actually need it.