Git Command Cheat Sheet
Browse 40+ Git commands organized across 10 categories — Setup & Config, Staging, Branching, Sharing, Inspection, Undoing Changes, Stashing, Rewriting History, and Advanced. Search by command name, description, flag, or example. Click any command to copy it to your clipboard instantly. No signup required.
Browse 44 Git commands organized by category. Search by command name, description, flags, or examples. Click any command or example to copy it to your clipboard. Expand any card to see available flags.
Setup & Config
5 commandsgit config --global user.name "[name]"Set the name that will be attached to your commits and tags.
git config --global user.name "Jane Doe"git config --global user.email "[email]"Set the email address that will be attached to your commits and tags.
git config --global user.email "jane@example.com"git config --global core.editor "[editor]"Set the default text editor for commit messages.
git config --global core.editor "code --wait"git config --listList all Git configuration settings currently in effect.
git config --listgit config --global alias.[alias] "[command]"Create a shortcut alias for a Git command.
git config --global alias.st statusGetting Started
2 commandsgit initInitialize a new local Git repository in the current directory.
git initgit clone [url]Clone a remote repository into a new local directory.
git clone https://github.com/user/repo.gitStaging & Snapshots
6 commandsgit statusShow the working tree status — staged, unstaged, and untracked files.
git statusgit add [file]Stage a file or directory for the next commit.
git add src/index.tsgit commit -m "[message]"Record staged changes to the repository with a commit message.
git commit -m "feat: add user authentication"git diffShow unstaged changes between your working directory and the index.
git diffgit rm [file]Remove a file from the working tree and stage the deletion.
git rm old-file.txtgit mv [old] [new]Move or rename a file and stage the change.
git mv old-name.ts new-name.tsBranching & Merging
6 commandsgit branchList, create, or delete branches.
git branch feature/logingit checkout [branch]Switch to an existing branch or restore working tree files.
git checkout maingit switch [branch]Switch to a branch (modern replacement for git checkout for branch switching).
git switch feature/logingit merge [branch]Merge the specified branch into the current branch.
git merge feature/logingit rebase [branch]Reapply commits on top of another base branch.
git rebase maingit cherry-pick [commit]Apply the changes from a specific commit onto the current branch.
git cherry-pick a1b2c3dSharing & Updating
4 commandsgit remote add [name] [url]Add a new remote repository connection.
git remote add origin https://github.com/user/repo.gitgit fetch [remote]Download objects and refs from a remote without merging.
git fetch origingit pull [remote] [branch]Fetch from a remote and integrate (merge or rebase) into the current branch.
git pull origin maingit push [remote] [branch]Upload local branch commits to the remote repository.
git push origin mainInspection & Comparison
4 commandsgit logShow the commit history for the current branch.
git log --oneline --graph --allgit show [commit]Show information about a commit, tag, or tree object.
git show a1b2c3dgit blame [file]Show what revision and author last modified each line of a file.
git blame src/index.tsgit tag [name]Create, list, or delete tags.
git tag v1.0.0Undoing Changes
4 commandsgit restore [file]Discard changes in the working directory (modern replacement for checkout --).
git restore src/index.tsgit revert [commit]Create a new commit that undoes the changes from a previous commit.
git revert a1b2c3dgit reset [commit]Reset the current HEAD to a specified state.
git reset --soft HEAD~1git cleanRemove untracked files from the working directory.
git clean -fdStashing
5 commandsgit stashTemporarily save uncommitted changes to a stash stack.
git stashgit stash popApply the most recent stash and remove it from the stash stack.
git stash popgit stash listList all stashed changesets.
git stash listgit stash apply [stash]Apply a stash without removing it from the stash stack.
git stash apply stash@{2}git stash drop [stash]Remove a single stash entry from the stash stack.
git stash drop stash@{0}Rewriting History
3 commandsgit commit --amendModify the most recent commit — change message or add staged changes.
git commit --amend -m "fix: corrected typo in auth module"git rebase -i [base]Interactively rebase — reorder, squash, edit, or drop commits.
git rebase -i HEAD~3git reflogShow a log of all HEAD movements — useful for recovering lost commits.
git reflogAdvanced
5 commandsgit bisect startUse binary search to find the commit that introduced a bug.
git bisect start
git bisect bad
git bisect good v1.0git submodule add [url]Add a Git repository as a submodule inside another repository.
git submodule add https://github.com/user/lib.git libs/libgit worktree add [path] [branch]Check out a branch into a new working directory without cloning.
git worktree add ../hotfix hotfix/urgentgit archive [branch]Create a tar or zip archive of a tree from a branch or commit.
git archive --format=zip HEAD > release.zipgit shortlogSummarize git log output grouped by author.
git shortlog -snWhy Use Our Git Command Cheat Sheet?
Fast, searchable, and comprehensive Git command reference
Instant Git Command Search
Find any Git command instantly by searching command names, descriptions, flags, or examples. Our git command cheat sheet searches across all 40+ commands and their flags in milliseconds — no page reloads, no waiting.
Secure Git Cheat Sheet Online
Our git command cheat sheet runs entirely in your browser with no server requests. Your searches and interactions never leave your device, ensuring complete privacy when you use our git cheat sheet online.
Git Cheat Sheet — No Installation
Use our git command cheat sheet directly in any browser with no downloads, plugins, or account required. Look up git commands from any device — desktop, tablet, or mobile — completely free.
Commands, Flags, and Examples
Every entry in our git command cheat sheet includes a description, a real-world example, and expandable flags with explanations. Click any command or example to copy it to your clipboard instantly.
Common Use Cases for Git Command Cheat Sheet
Practical applications for our interactive Git command reference
Learning Git for the First Time
Use our git command cheat sheet to learn the most important git commands in context. Each command includes a plain-English description and a real example, making it easy to understand what each git command does before running it.
Recovering from Mistakes
Search our git cheat sheet for "undo", "revert", or "reset" to quickly find the right command for your situation. The Undoing Changes category covers git restore, git revert, git reset, and git clean with flag explanations.
Code Review and Collaboration
Look up git commands for branching, merging, and rebasing workflows. Our git command cheat sheet covers git branch, git merge, git rebase, and git cherry-pick with all their important flags.
CI/CD and Automation Scripts
Find the exact git command syntax for your automation scripts. Search for flags like "--no-ff", "--force-with-lease", or "--depth" to get the precise command format needed for your pipeline.
Debugging and Inspection
Use the Inspection & Comparison category to find git log, git blame, git show, and git diff commands with their most useful flags. Copy the exact command you need for investigating commit history or file changes.
Advanced Git Workflows
Explore the Advanced category for git bisect, git submodule, git worktree, and git archive commands. Our git cheat sheet covers these less-common but powerful commands with examples and flag explanations.
Understanding Git Commands
Core Git concepts and how the most important commands work
What is Git?
Git is a distributed version control system that tracks changes in source code during software development. Created by Linus Torvalds in 2005, Git allows multiple developers to work on the same codebase simultaneously, maintain a complete history of every change, and branch off to experiment without affecting the main codebase. Our git command cheat sheet covers the essential git commands across 10 categories — from initial setup and staging to advanced workflows like bisect and worktrees.
How Our Git Command Cheat Sheet Works
- Search or Browse: Type any keyword into the search box to instantly filter commands by name, description, flags, or examples. Or use the category pills to browse commands by workflow area — Staging, Branching, Undoing Changes, and more.
- Read and Expand:Each card shows the command, a plain-English description, and a real-world example. Click “Show flags” to expand the available options for that command with explanations of each flag.
- Copy and Use: Click the copy icon next to any command or example to copy it to your clipboard instantly. All processing runs locally in your browser — no data is sent to any server.
Git Command Categories
- Setup & Config: Configure your identity, editor, and aliases with
git config— these settings apply globally to all repositories on your machine. - Staging & Snapshots: The core workflow — use
git add,git commit, andgit diffto stage and record changes to your repository. - Branching & Merging: Use
git branch,git switch,git merge, andgit rebaseto manage parallel lines of development and integrate changes. - Undoing Changes: Use
git restore,git revert, andgit resetto undo changes — each with different levels of permanence and safety.
git reset vs git revert vs git restore
These three commands are often confused. git restore discards uncommitted changes in your working directory or unstages files — it only affects your local working tree and is the safest option. git revert creates a new commit that undoes a previous commit — it is safe to use on shared branches because it preserves history. git reset moves the HEAD pointer and optionally modifies the index and working tree — use --soft to keep changes staged, --mixed to unstage them, or --hard to discard them entirely. Never use git reset --hard on commits that have already been pushed to a shared remote.
Related Tools
JSON to YAML
Convert JSON to YAML format instantly - Free online JSON to YAML converter
XML to YAML
Convert XML to YAML format for configuration migration - Free online XML to YAML converter
CSV to YAML
Convert CSV spreadsheet data to YAML format - Free online CSV to YAML converter
TSV to YAML
Convert TSV tab-separated data to YAML format - Free online TSV to YAML converter
Frequently Asked Questions About Git Command Cheat Sheet
Common questions about Git commands, workflows, and version control
A git command cheat sheet is a quick reference guide listing the most important git commands with descriptions, flags, and examples. Our interactive git command cheat sheet lets you search across all commands and copy any command to your clipboard instantly — all running locally in your browser.
git fetch downloads changes from the remote repository but does not integrate them into your working branch — it updates your remote-tracking branches only. git pull is essentially git fetch followed by git merge (or git rebase with --rebase). Use git fetch when you want to review changes before integrating them, and git pull when you want to update your branch immediately.
git merge integrates changes from one branch into another by creating a new merge commit, preserving the full history of both branches. git rebase replays your commits on top of another branch, creating a linear history without a merge commit. Use merge for shared branches to preserve history, and rebase for local feature branches to keep a clean linear history before merging.
Use git reset --soft HEAD~1 to undo the last commit while keeping all changes staged. Use git reset --mixed HEAD~1 (the default) to undo the commit and unstage the changes, keeping them in your working directory. Use git reset --hard HEAD~1 only if you want to permanently discard the changes — this cannot be undone unless you have the commit hash in your reflog.
git stash temporarily saves your uncommitted changes (both staged and unstaged) to a stash stack, giving you a clean working directory. This is useful when you need to switch branches without committing incomplete work. Use git stash pop to restore the most recent stash, or git stash apply stash@{n} to apply a specific stash without removing it from the stack.
Yes. Our git command cheat sheet runs entirely in your browser — all 40+ commands are loaded locally with no server requests. Your searches and interactions never leave your device.
Yes! Our git command cheat sheet is 100% free with no signup, no account, no usage limits, and no advertisements. Use it as many times as you need.
git rebase -i (interactive rebase) lets you rewrite your commit history before sharing it. You can squash multiple commits into one, reorder commits, edit commit messages, or drop commits entirely. It is most useful for cleaning up a messy feature branch before merging it into main. Never use interactive rebase on commits that have already been pushed to a shared remote branch.
git switch was introduced in Git 2.23 as a more focused replacement for the branch-switching functionality of git checkout. git checkout does many things — it switches branches, restores files, and checks out commits. git switch only switches branches, making its intent clearer. git restore was introduced at the same time to handle the file-restoration use case. Both git switch and git restore are now the recommended commands for their respective tasks.