Complete Git commands cheat sheet covering basic operations, branching, merging, history, and advanced workflows. Essential reference for every developer using version control.
Search all Git shortcuts interactively
Interactive Shortcut Finder| Shortcut | Action | Description |
|---|---|---|
| git init | Initialize repo | Initialize a new Git repository. |
| git clone [URL] | Clone repo | Clone a remote repository locally. |
| git status | Check status | Show the status of changed files. |
| git add . | Stage all | Stage all changed files. |
| git add [file] | Stage file | Stage a specific file. |
| git commit -m [msg] | Commit | Commit staged changes with a message. |
| git push | Push | Push local commits to the remote repo. |
| git pull | Pull | Fetch and merge remote changes. |
| git fetch | Fetch | Fetch remote changes without merging. |
| Shortcut | Action | Description |
|---|---|---|
| git branch | List branches | List local branches. |
| git branch [name] | Create branch | Create a new branch. |
| git checkout [branch] | Switch branch | Switch to another branch. |
| git checkout -b [name] | Create & switch | Create and switch to a new branch. |
| git merge [branch] | Merge | Merge another branch into current. |
| git branch -d [name] | Delete branch | Delete a local branch. |
| git rebase [branch] | Rebase | Rebase current branch onto another. |
| Shortcut | Action | Description |
|---|---|---|
| git log | Commit history | Show commit history. |
| git log --oneline | One-line log | Show commits in one-line format. |
| git diff | Show diff | Show unstaged changes. |
| git reset HEAD [file] | Unstage | Unstage a staged file. |
| git reset --hard HEAD~1 | Undo last commit | Completely undo the last commit. |
| git stash | Stash changes | Temporarily save current changes. |
| git stash pop | Apply stash | Restore stashed changes. |
| git cherry-pick [hash] | Cherry-pick | Apply a specific commit to current branch. |
Browse shortcuts for 269 platforms
Explore AllDaily git is five commands: status → add → commit → pull → push. The habit that prevents most accidents is running git status before and after anything else — it tells you the branch, what's staged, and what would be committed. git add . stages everything under the current directory; prefer naming files (git add file) when a change set mixes concerns, and let git log --oneline be the sanity check that history looks the way you think it does.
git checkout -b name creates and switches in one step (newer git also offers git switch -c). Merging brings a branch's work in with history intact; git rebase replays your commits on top of another branch for a linear history — the working rule is to rebase only commits that haven't been pushed anywhere shared, because rebase rewrites them. git branch -d deletes a merged branch and refuses an unmerged one; that refusal is a feature, not an obstacle.
Gentlest first: git stash shelves uncommitted work and stash pop restores it — ideal for “wrong branch” moments. git reset HEAD file unstages without touching the file's contents. git cherry-pick copies a single commit onto the current branch. At the destructive end, git reset --hard HEAD~1 deletes the last commit and its changes from the working tree — use it only when you truly want the work gone, and remember committed-then-reset work is recoverable via git reflog for a grace period.
fetch downloads remote changes without touching your working branch; pull is fetch plus merge into the current branch. Fetch first when you want to inspect before integrating.
Keep the changes: git reset HEAD~1 (they return to your working tree, unstaged). Discard them entirely: git reset --hard HEAD~1 — destructive, so be sure.
Rebase local, unpushed commits to keep history linear; merge anything already shared. Rewriting pushed commits forces everyone else to untangle it.
Uncommitted tracked changes (staged and unstaged). git stash pop restores the most recent stash and drops it; git stash apply restores but keeps it in the stash list.
git cherry-pick <hash> from the target branch. It creates a new commit with the same changes — the original stays where it was.
-d refuses if the branch isn't merged, protecting unmerged work. If you're certain, -D force-deletes.
Open your assistant with this page preloaded as the source — great for follow-up questions like "which of these work in other apps?"