Git Commands Table

–click a command to copy it
CommandActionWhen to use
git initCreate a new repositoryStarting a project from scratch
git clone <url>Copy an existing repositoryJoining a project or deploying
git statusShow working tree stateBefore every commit - always
git add .Stage all changesBefore commit; use -p for selective staging
git commit -m "msg"Save a snapshotAfter staging; write clear messages
git log --onelineShow commit historyReview what happened; --graph shows branches
git diffShow unstaged changesReview before staging; --staged for staged
git branchList or create branchesgit branch <name> creates; -d deletes
git checkout -b <name>Create and switch to a branchStarting new work; modern: git switch -c
git merge <branch>Combine branchesAfter finishing feature work
git rebase <base>Replay commits on a new baseCleaning up before merge; --abort to escape
git push origin <branch>Upload to remoteAfter committing; -u sets upstream on first push
git pull --rebaseFetch and rebase onto remoteSync with team before pushing
git reset --soft HEAD~1Undo last commit, keep changesWrong commit message or forgot a file
git revert <hash>Undo a commit with a new commitSafe undo on shared branches - never rewrite shared history
git stashTemporarily save uncommitted workSwitch branches without committing; git stash pop to restore
git cherry-pick <hash>Apply one commit to another branchHotfix or selectively moving changes
Commands follow the official Git documentation at git-scm.com. The golden rules: git status before every commit, git pull --rebase before every push, and git revert (not reset) on shared branches - reset rewrites history, revert adds a new commit that undoes the old one. The three commands that save the most time: git stash (park work and switch branches), git cherry-pick (steal one commit from another branch), and git commit --amend (fix the last commit before pushing). Bottom line: Git has 150+ subcommands, but 17 cover 95% of daily use - the table above is that 95%. Tool neighbours: Bash operators table, HTTP methods table, IPv4 subnet cheatsheet, chmod calculator.

Git has 150+ subcommands, but seventeen cover virtually all daily work: init, clone, status, add, commit, log, diff, branch, checkout, merge, rebase, push, pull, reset, revert, stash and cherry-pick. This table groups them by workflow and shows when to reach for each one.

The golden rules that prevent disasters: git status before every commit, git pull --rebase before every push, and git revert (not reset) on shared branches - because revert adds a new commit while reset rewrites history.

How to use

  1. Filter by command name or action - commit, branch, undo, remote - to find the one you need.
  2. Click any command to copy it into your terminal or documentation.
  3. Use the category chips to browse by workflow: commits, branching, undoing, remote.

Frequently asked questions

What is the difference between git reset and git revert?

git reset moves the branch pointer backward, rewriting history - dangerous on shared branches because everyone else’s commits diverge. git revert creates a new commit that undoes an old one - safe on shared branches because history is preserved. Rule: revert for anything already pushed, reset only for local mistakes.

What is the difference between git merge and git rebase?

Merge creates a merge commit with two parents, preserving the actual branch topology. Rebase replays your commits on top of the target branch, creating a linear history. Merge is safe for shared branches; rebase is for cleaning up local work before sharing. The golden rule: never rebase commits that others have already pulled.

What does git stash do?

git stash temporarily saves uncommitted changes and reverts the working tree to the last commit - letting you switch branches without committing half-finished work. git stash pop restores the changes. The stash is a stack: multiple stashes can be stacked with git stash, and retrieved with git stash pop --stash N.

What is the difference between git fetch and git pull?

git fetch downloads new commits from the remote but does not merge them - you can inspect them first with git log origin/main. git pull = fetch + merge (or rebase with --rebase). The safe pattern: fetch first, review with git log HEAD..origin/main, then merge or rebase deliberately.

Related tools