Dev Tool

Git Commands — The Ones You'll Actually Use

Quick reference for common Git commands — searchable by category

AllOmnitools Editorial Team

Setup & Basics

git initInitialize a new repository
git clone <url>Clone a remote repository
git config --global user.name "Name"Set global username
git config --global user.email "email"Set global email

Staging & Committing

git statusShow working tree status
git add <file>Stage a file
git add .Stage all changes
git commit -m "message"Commit staged changes
git commit --amendAmend last commit

Branching & Merging

git branchList branches
git branch <name>Create a branch
git checkout <branch>Switch to branch
git checkout -b <branch>Create and switch to branch
git merge <branch>Merge branch into current
git branch -d <branch>Delete a branch

Remote & Push/Pull

git remote -vList remotes
git push origin <branch>Push to remote
git pullFetch and merge from remote
git fetchFetch from remote (no merge)

Log & History

git logShow commit history
git log --onelineCompact commit history
git diffShow unstaged changes
git stashStash current changes
git stash popApply stashed changes

Git commands you actually use every day

This is the reference for the commands that come up in real work — not the full man page. Grouped by what you're trying to do, with the flags that matter.

Starting and cloning

  • git init — create a new repo in the current folder
  • git clone <url> — clone a remote repo
  • git clone <url> --depth 1 — shallow clone, only latest commit (faster for CI)

Branching

  • git checkout -b feature-name — create and switch to a new branch
  • git switch -c feature-name — same as above (newer syntax)
  • git branch -d feature-name — delete a local branch (safe — won't delete unmerged)
  • git branch -D feature-name — force delete even if unmerged
  • git push origin --delete feature-name — delete remote branch

Staging and committing

  • git add -p — interactively stage chunks (best way to make clean commits)
  • git commit -m "message" — commit with inline message
  • git commit --amend --no-edit — add staged changes to last commit without changing message
  • git commit --amend -m "new message" — fix last commit message

Stashing

  • git stash — stash all uncommitted changes
  • git stash pop — apply most recent stash and remove it
  • git stash list — see all stashes
  • git stash apply stash@{2} — apply a specific stash without removing it

Undoing changes

  • git restore filename — discard unstaged changes to a file
  • git reset HEAD~1 — undo last commit, keep changes staged
  • git reset --hard HEAD~1 — undo last commit, discard changes
  • git revert HEAD — safe undo: new commit that reverses last commit
  • git reflog — view full history of HEAD changes (lifesaver after force-push)

Complete Developer Toolkit

This Git cheat sheet works best alongside our Git error guide — use the cheat sheet to find the right command and the error guide when something goes wrong. Our diff checker replicates git diff in the browser — paste two versions of a file to visualize what changed without needing a terminal. For automating git operations in CI/CD pipelines, our cron generator schedules automated git pulls or deployments, and our Linux terminal cheat sheet covers the shell commands that surround those git operations.

When reviewing pull requests that include config file changes, our JSON formatter validates modified package.json, tsconfig.json, or API config files. The regex tester helps you write git log --grep patterns and .gitignore glob expressions. For repos that include cron jobs in their deployment process, our crontab descriptor decodes those schedule expressions into plain English. Our SSL expiry checker and DNS lookup diagnose the connection issues that cause git push failures to remote repositories.

FAQ

Merge preserves history exactly as it happened — you get a merge commit and both branch histories. Rebase replays your commits on top of another branch, giving a linear history. Rebase is cleaner but rewrites commit hashes, so never rebase commits that others have already pulled.