All Shortcuts

Git Shortcuts & Commands — Complete Cheat Sheet (82)

Complete Git commands cheat sheet covering basic operations, branching, merging, history, and advanced workflows. Essential reference for every developer using version control.

Related Shortcut Pages

Docker npm / yarn AWS CLI PowerShell tmux GNU Screen

Search all Git shortcuts interactively

Interactive Shortcut Finder

Main porcelain commands (44)

ShortcutActionWhat it does
git addAdd file contents to the indexAdd file contents to the index.
git amApply a series of patches from a mailboxApply a series of patches from a mailbox.
git archiveCreate an archive of files from a named treeCreate an archive of files from a named tree.
git backfillDownload missing objects in a partial cloneDownload missing objects in a partial clone.
git bisectUse binary search to find the commit that introduced a bugUse binary search to find the commit that introduced a bug.
git branchList, create, or delete branchesList, create, or delete branches.
git bundleMove objects and refs by archiveMove objects and refs by archive.
git checkoutSwitch branches or restore working tree filesSwitch branches or restore working tree files.
git cherry-pickApply the changes introduced by some existing commitsApply the changes introduced by some existing commits.
git citoolGraphical alternative to git-commitGraphical alternative to git-commit.
git cleanRemove untracked files from the working treeRemove untracked files from the working tree.
git cloneClone a repository into a new directoryClone a repository into a new directory.
git commitRecord changes to the repositoryRecord changes to the repository.
git describeGive an object a human readable name based on an available refGive an object a human readable name based on an available ref.
git diffShow changes between commits, commit and working tree, etcShow changes between commits, commit and working tree, etc.
git fetchDownload objects and refs from another repositoryDownload objects and refs from another repository.
git format-patchPrepare patches for e-mail submissionPrepare patches for e-mail submission.
git gcCleanup unnecessary files and optimize the local repositoryCleanup unnecessary files and optimize the local repository.
git grepPrint lines matching a patternPrint lines matching a pattern.
git guiA portable graphical interface to GitA portable graphical interface to Git.
git historyEXPERIMENTAL: Rewrite historyEXPERIMENTAL: Rewrite history.
git initCreate an empty Git repository or reinitialize an existing oneCreate an empty Git repository or reinitialize an existing one.
git logShow commit logsShow commit logs.
git maintenanceRun tasks to optimize Git repository dataRun tasks to optimize Git repository data.
git mergeJoin two or more development histories togetherJoin two or more development histories together.
git mvMove or rename a file, a directory, or a symlinkMove or rename a file, a directory, or a symlink.
git notesAdd or inspect object notesAdd or inspect object notes.
git pullFetch from and integrate with another repository or a local branchFetch from and integrate with another repository or a local branch.
git pushUpdate remote refs along with associated objectsUpdate remote refs along with associated objects.
git range-diffCompare two commit ranges (e.g. two versions of a branch)Compare two commit ranges (e.g. two versions of a branch).
git rebaseReapply commits on top of another base tipReapply commits on top of another base tip.
git resetSet HEAD or the index to a known stateSet HEAD or the index to a known state.
git restoreRestore working tree filesRestore working tree files.
git revertRevert some existing commitsRevert some existing commits.
git rmRemove files from the working tree and from the indexRemove files from the working tree and from the index.
git shortlogSummarize git log outputSummarize git log output.
git showShow various types of objectsShow various types of objects.
git sparse-checkoutReduce your working tree to a subset of tracked filesReduce your working tree to a subset of tracked files.
git stashStash the changes in a dirty working directory awayStash the changes in a dirty working directory away.
git statusShow the working tree statusShow the working tree status.
git submoduleInitialize, update or inspect submodulesInitialize, update or inspect submodules.
git switchSwitch branchesSwitch branches.
git tagCreate, list, delete or verify tagsCreate, list, delete or verify tags.
git worktreeManage multiple working treesManage multiple working trees.

Ancillary Commands (28)

ShortcutActionWhat it does
git configGet and set repository or global optionsGet and set repository or global options.
git fast-exportGit data exporterGit data exporter.
git fast-importBackend for fast Git data importersBackend for fast Git data importers.
git filter-branchRewrite branchesRewrite branches.
git mergetoolRun merge conflict resolution tools to resolve merge conflictsRun merge conflict resolution tools to resolve merge conflicts.
git pack-refsPack heads and tags for efficient repository accessPack heads and tags for efficient repository access.
git prunePrune all unreachable objects from the object databasePrune all unreachable objects from the object database.
git reflogManage reflog informationManage reflog information.
git refsLow-level access to refsLow-level access to refs.
git remoteManage set of tracked repositoriesManage set of tracked repositories.
git repackPack unpacked objects in a repositoryPack unpacked objects in a repository.
git replaceCreate, list, delete refs to replace objectsCreate, list, delete refs to replace objects.
git annotateAnnotate file lines with commit informationAnnotate file lines with commit information.
git blameShow what revision and author last modified each line of a fileShow what revision and author last modified each line of a file.
git bugreportCollect information for user to file a bug reportCollect information for user to file a bug report.
git count-objectsCount unpacked number of objects and their disk consumptionCount unpacked number of objects and their disk consumption.
git diagnoseGenerate a zip archive of diagnostic informationGenerate a zip archive of diagnostic information.
git difftoolShow changes using common diff toolsShow changes using common diff tools.
git fsckVerifies the connectivity and validity of the objects in the databaseVerifies the connectivity and validity of the objects in the database.
git helpDisplay help information about GitDisplay help information about Git.
git instawebInstantly browse your working repository in gitwebInstantly browse your working repository in gitweb.
git merge-treePerform merge without touching index or working treePerform merge without touching index or working tree.
git rerereReuse recorded resolution of conflicted mergesReuse recorded resolution of conflicted merges.
git show-branchShow branches and their commitsShow branches and their commits.
git verify-commitCheck the GPG signature of commitsCheck the GPG signature of commits.
git verify-tagCheck the GPG signature of tagsCheck the GPG signature of tags.
git versionDisplay version information about GitDisplay version information about Git.
git whatchangedShow logs with differences each commit introducesShow logs with differences each commit introduces.

Interacting with Others (10)

ShortcutActionWhat it does
git archimportImport a GNU Arch repository into GitImport a GNU Arch repository into Git.
git cvsexportcommitExport a single commit to a CVS checkoutExport a single commit to a CVS checkout.
git cvsimportSalvage your data out of another SCM people love to hateSalvage your data out of another SCM people love to hate.
git cvsserverA CVS server emulator for GitA CVS server emulator for Git.
git imap-sendSend a collection of patches from stdin to an IMAP folderSend a collection of patches from stdin to an IMAP folder.
git p4Import from and submit to Perforce repositoriesImport from and submit to Perforce repositories.
git quiltimportApplies a quilt patchset onto the current branchApplies a quilt patchset onto the current branch.
git request-pullGenerates a summary of pending changesGenerates a summary of pending changes.
git send-emailSend a collection of patches as emailsSend a collection of patches as emails.
git svnBidirectional operation between a Subversion repository and GitBidirectional operation between a Subversion repository and Git.
📜 Source: git-scm.com — git(1) manual, Git commands. Command names and one-line descriptions from the git(1) manual: main porcelain, ancillary and “interacting with others” commands. Plumbing commands are omitted. Checked 2026-09-06. How we verify ›

Browse shortcuts for 268 platforms

Explore All
🔧 Spotted an error or a missing shortcut? Suggest an edit on GitHub — every accepted fix goes live on this page, the API and the CLI.

The 80% loop

Daily 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.

Branching: cheap to make, cheap to delete

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.

The undo toolbox, sorted by blast radius

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.

Frequently asked questions

What is the difference between git fetch and git pull?

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.

How do I undo my last git commit?

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.

When should I rebase instead of merge in git?

Rebase local, unpushed commits to keep history linear; merge anything already shared. Rewriting pushed commits forces everyone else to untangle it.

What does git stash actually store?

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.

How do I copy one commit to another branch?

git cherry-pick <hash> from the target branch. It creates a new commit with the same changes — the original stays where it was.

Why won't git branch -d delete my branch?

-d refuses if the branch isn't merged, protecting unmerged work. If you're certain, -D force-deletes.

🤖 Ask AI about Git shortcuts

Open your assistant with this page preloaded as the source — great for follow-up questions like "which of these work in other apps?"

ChatGPT Claude Perplexity Gemini Grok