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 | What it does |
|---|---|---|
| git add | Add file contents to the index | Add file contents to the index. |
| git am | Apply a series of patches from a mailbox | Apply a series of patches from a mailbox. |
| git archive | Create an archive of files from a named tree | Create an archive of files from a named tree. |
| git backfill | Download missing objects in a partial clone | Download missing objects in a partial clone. |
| git bisect | Use binary search to find the commit that introduced a bug | Use binary search to find the commit that introduced a bug. |
| git branch | List, create, or delete branches | List, create, or delete branches. |
| git bundle | Move objects and refs by archive | Move objects and refs by archive. |
| git checkout | Switch branches or restore working tree files | Switch branches or restore working tree files. |
| git cherry-pick | Apply the changes introduced by some existing commits | Apply the changes introduced by some existing commits. |
| git citool | Graphical alternative to git-commit | Graphical alternative to git-commit. |
| git clean | Remove untracked files from the working tree | Remove untracked files from the working tree. |
| git clone | Clone a repository into a new directory | Clone a repository into a new directory. |
| git commit | Record changes to the repository | Record changes to the repository. |
| git describe | Give an object a human readable name based on an available ref | Give an object a human readable name based on an available ref. |
| git diff | Show changes between commits, commit and working tree, etc | Show changes between commits, commit and working tree, etc. |
| git fetch | Download objects and refs from another repository | Download objects and refs from another repository. |
| git format-patch | Prepare patches for e-mail submission | Prepare patches for e-mail submission. |
| git gc | Cleanup unnecessary files and optimize the local repository | Cleanup unnecessary files and optimize the local repository. |
| git grep | Print lines matching a pattern | Print lines matching a pattern. |
| git gui | A portable graphical interface to Git | A portable graphical interface to Git. |
| git history | EXPERIMENTAL: Rewrite history | EXPERIMENTAL: Rewrite history. |
| git init | Create an empty Git repository or reinitialize an existing one | Create an empty Git repository or reinitialize an existing one. |
| git log | Show commit logs | Show commit logs. |
| git maintenance | Run tasks to optimize Git repository data | Run tasks to optimize Git repository data. |
| git merge | Join two or more development histories together | Join two or more development histories together. |
| git mv | Move or rename a file, a directory, or a symlink | Move or rename a file, a directory, or a symlink. |
| git notes | Add or inspect object notes | Add or inspect object notes. |
| git pull | Fetch from and integrate with another repository or a local branch | Fetch from and integrate with another repository or a local branch. |
| git push | Update remote refs along with associated objects | Update remote refs along with associated objects. |
| git range-diff | Compare two commit ranges (e.g. two versions of a branch) | Compare two commit ranges (e.g. two versions of a branch). |
| git rebase | Reapply commits on top of another base tip | Reapply commits on top of another base tip. |
| git reset | Set HEAD or the index to a known state | Set HEAD or the index to a known state. |
| git restore | Restore working tree files | Restore working tree files. |
| git revert | Revert some existing commits | Revert some existing commits. |
| git rm | Remove files from the working tree and from the index | Remove files from the working tree and from the index. |
| git shortlog | Summarize git log output | Summarize git log output. |
| git show | Show various types of objects | Show various types of objects. |
| git sparse-checkout | Reduce your working tree to a subset of tracked files | Reduce your working tree to a subset of tracked files. |
| git stash | Stash the changes in a dirty working directory away | Stash the changes in a dirty working directory away. |
| git status | Show the working tree status | Show the working tree status. |
| git submodule | Initialize, update or inspect submodules | Initialize, update or inspect submodules. |
| git switch | Switch branches | Switch branches. |
| git tag | Create, list, delete or verify tags | Create, list, delete or verify tags. |
| git worktree | Manage multiple working trees | Manage multiple working trees. |
| Shortcut | Action | What it does |
|---|---|---|
| git config | Get and set repository or global options | Get and set repository or global options. |
| git fast-export | Git data exporter | Git data exporter. |
| git fast-import | Backend for fast Git data importers | Backend for fast Git data importers. |
| git filter-branch | Rewrite branches | Rewrite branches. |
| git mergetool | Run merge conflict resolution tools to resolve merge conflicts | Run merge conflict resolution tools to resolve merge conflicts. |
| git pack-refs | Pack heads and tags for efficient repository access | Pack heads and tags for efficient repository access. |
| git prune | Prune all unreachable objects from the object database | Prune all unreachable objects from the object database. |
| git reflog | Manage reflog information | Manage reflog information. |
| git refs | Low-level access to refs | Low-level access to refs. |
| git remote | Manage set of tracked repositories | Manage set of tracked repositories. |
| git repack | Pack unpacked objects in a repository | Pack unpacked objects in a repository. |
| git replace | Create, list, delete refs to replace objects | Create, list, delete refs to replace objects. |
| git annotate | Annotate file lines with commit information | Annotate file lines with commit information. |
| git blame | Show what revision and author last modified each line of a file | Show what revision and author last modified each line of a file. |
| git bugreport | Collect information for user to file a bug report | Collect information for user to file a bug report. |
| git count-objects | Count unpacked number of objects and their disk consumption | Count unpacked number of objects and their disk consumption. |
| git diagnose | Generate a zip archive of diagnostic information | Generate a zip archive of diagnostic information. |
| git difftool | Show changes using common diff tools | Show changes using common diff tools. |
| git fsck | Verifies the connectivity and validity of the objects in the database | Verifies the connectivity and validity of the objects in the database. |
| git help | Display help information about Git | Display help information about Git. |
| git instaweb | Instantly browse your working repository in gitweb | Instantly browse your working repository in gitweb. |
| git merge-tree | Perform merge without touching index or working tree | Perform merge without touching index or working tree. |
| git rerere | Reuse recorded resolution of conflicted merges | Reuse recorded resolution of conflicted merges. |
| git show-branch | Show branches and their commits | Show branches and their commits. |
| git verify-commit | Check the GPG signature of commits | Check the GPG signature of commits. |
| git verify-tag | Check the GPG signature of tags | Check the GPG signature of tags. |
| git version | Display version information about Git | Display version information about Git. |
| git whatchanged | Show logs with differences each commit introduces | Show logs with differences each commit introduces. |
| Shortcut | Action | What it does |
|---|---|---|
| git archimport | Import a GNU Arch repository into Git | Import a GNU Arch repository into Git. |
| git cvsexportcommit | Export a single commit to a CVS checkout | Export a single commit to a CVS checkout. |
| git cvsimport | Salvage your data out of another SCM people love to hate | Salvage your data out of another SCM people love to hate. |
| git cvsserver | A CVS server emulator for Git | A CVS server emulator for Git. |
| git imap-send | Send a collection of patches from stdin to an IMAP folder | Send a collection of patches from stdin to an IMAP folder. |
| git p4 | Import from and submit to Perforce repositories | Import from and submit to Perforce repositories. |
| git quiltimport | Applies a quilt patchset onto the current branch | Applies a quilt patchset onto the current branch. |
| git request-pull | Generates a summary of pending changes | Generates a summary of pending changes. |
| git send-email | Send a collection of patches as emails | Send a collection of patches as emails. |
| git svn | Bidirectional operation between a Subversion repository and Git | Bidirectional operation between a Subversion repository and Git. |
Browse shortcuts for 268 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?"