Git Command Cheatsheet
Quick reference guide for common Git commands with examples
About this ToolHow it works, benefits & use casesTap to collapse
A practical, searchable reference for the Git commands you reach for every day, organised the way the official docs are — Setup & Config, Getting Started, Basic Snapshotting, Branching & Merging, Sharing & Updating, Inspection & Comparison, and more. Each command appears as a card with the command itself, a one-line explanation of what it does, and, where helpful, a concrete example showing real arguments. Both the command and its example have their own copy buttons, so you can grab exactly the form you need. A search box filters across command names and descriptions in real time, and category chips let you jump to a section. A short tips panel rounds it out with habits like checking git status often, reviewing diffs before committing, and using git reflog to recover lost work. Everything is local to your browser.
How to Use
- 1Type into "Search commands" to filter by command name or description as you type.
- 2Or click a category chip — Branching & Merging, Sharing & Updating, and so on — to browse one section.
- 3Read each card for the command, what it does, and an example with real arguments where provided.
- 4Click the copy button next to the command, or next to the example, to copy exactly that text.
- 5Skim the Git Tips panel at the bottom for workflow habits worth adopting.
Key Benefits
- Commands grouped by the same categories as the official Git documentation
- Each entry includes a plain-language description of what the command does
- Concrete usage examples with real arguments, not just bare command names
- Separate copy buttons for the command and its example
- Live search across both command names and descriptions
- Category chips to jump straight to setup, branching, sharing, inspection, and more
- A tips panel with everyday Git habits and recovery tricks
Common Use Cases
- Recalling the exact flags for a command you use rarely, like git rebase or git stash
- Copying a ready-to-edit example instead of memorising argument order
- Onboarding a teammate who is new to Git with a categorised command list
- Looking up the right command to undo a mistake or recover lost commits
- Keeping a quick reference open beside the terminal while working
Setup & Config
git config --global user.name "[name]"Set your name for commit transactions
Example:
git config --global user.name "John Doe"git config --global user.email "[email]"Set your email for commit transactions
Example:
git config --global user.email "[email protected]"git config --listList all configuration settings
git config --global color.ui autoEnable colorization of command line output
Getting Started
git initInitialize a new Git repository
git clone [url]Clone a repository from a remote URL
Example:
git clone https://github.com/user/repo.gitBasic Snapshotting
git statusShow the working tree status
git add [file]Add file contents to the staging area
Example:
git add index.htmlgit add .Add all changes to the staging area
git add -AAdd all changes (new, modified, deleted) to the staging area
git commit -m "[message]"Commit staged changes with a message
Example:
git commit -m "Add new feature"git commit -am "[message]"Add and commit all tracked files with a message
Example:
git commit -am "Update readme"git commit --amendModify the last commit
git reset [file]Unstage a file while retaining changes
Example:
git reset index.htmlgit reset --hardReset the working directory and staging area to match the most recent commit
git rm [file]Remove a file from the working directory and staging area
Example:
git rm old-file.txtgit mv [file-original] [file-renamed]Move or rename a file
Example:
git mv old.txt new.txtBranching & Merging
git branchList all local branches
git branch [branch-name]Create a new branch
Example:
git branch feature/new-featuregit branch -d [branch-name]Delete a branch
Example:
git branch -d feature/old-featuregit branch -D [branch-name]Force delete a branch
Example:
git branch -D feature/abandonedgit checkout [branch-name]Switch to a branch
Example:
git checkout developgit checkout -b [branch-name]Create and switch to a new branch
Example:
git checkout -b feature/new-featuregit switch [branch-name]Switch to a branch (newer alternative to checkout)
Example:
git switch maingit switch -c [branch-name]Create and switch to a new branch
Example:
git switch -c feature/new-featuregit merge [branch]Merge a branch into the current branch
Example:
git merge feature/new-featuregit merge --no-ff [branch]Merge a branch with a merge commit
Example:
git merge --no-ff feature/new-featureSharing & Updating
git remote add [name] [url]Add a remote repository
Example:
git remote add origin https://github.com/user/repo.gitgit remote -vList all remote repositories
git fetch [remote]Download objects and refs from a remote repository
Example:
git fetch origingit pullFetch from and integrate with another repository
git pull --rebaseFetch and rebase the current branch
git pushUpdate remote refs along with associated objects
git push [remote] [branch]Push a branch to a remote repository
Example:
git push origin maingit push -u [remote] [branch]Push and set upstream branch
Example:
git push -u origin maingit push --tagsPush all tags to remote repository
Inspection & Comparison
git logShow commit logs
git log --onelineShow commit logs in condensed format
git log --graphShow commit logs with ASCII graph
git log --all --decorate --oneline --graphShow visual commit history (dog = decorations, oneline, graph)
git diffShow changes between commits, commit and working tree, etc.
git diff --stagedShow changes staged for commit
git diff [branch1] [branch2]Show differences between two branches
Example:
git diff main developgit show [commit]Show various types of objects
Example:
git show HEADStashing
git stashStash the changes in a dirty working directory
git stash save "[message]"Stash changes with a message
Example:
git stash save "Work in progress"git stash listList all stashes
git stash popApply and remove the most recent stash
git stash applyApply the most recent stash without removing it
git stash dropRemove the most recent stash
git stash clearRemove all stashes
Tagging
git tagList all tags
git tag [tag-name]Create a lightweight tag
Example:
git tag v1.0.0git tag -a [tag-name] -m "[message]"Create an annotated tag
Example:
git tag -a v1.0.0 -m "Release version 1.0.0"git tag -d [tag-name]Delete a tag
Example:
git tag -d v0.9.0git push [remote] [tag-name]Push a tag to remote
Example:
git push origin v1.0.0Undoing Changes
git checkout -- [file]Discard changes in working directory
Example:
git checkout -- index.htmlgit restore [file]Restore working tree files (newer alternative)
Example:
git restore index.htmlgit restore --staged [file]Unstage a file
Example:
git restore --staged index.htmlgit revert [commit]Create a new commit that undoes changes from a previous commit
Example:
git revert abc123git reset [commit]Reset current HEAD to the specified state
Example:
git reset HEAD~1git reset --soft [commit]Reset HEAD but keep changes staged
Example:
git reset --soft HEAD~1git reset --hard [commit]Reset HEAD and discard all changes
Example:
git reset --hard HEAD~1Advanced
git rebase [branch]Reapply commits on top of another base tip
Example:
git rebase maingit rebase -i [commit]Interactive rebase
Example:
git rebase -i HEAD~3git cherry-pick [commit]Apply the changes from a specific commit
Example:
git cherry-pick abc123git reflogShow reference logs (useful for recovering lost commits)
git bisect startStart binary search to find the commit that introduced a bug
git clean -fdRemove untracked files and directories
Git Tips
- Use
git statusfrequently to check your working directory state - Always review changes with
git diffbefore committing - Write clear, descriptive commit messages that explain the “why” not just the “what”
- Use branches to isolate features and bug fixes
- Pull before you push to avoid merge conflicts
- Use
git reflogto recover “lost” commits
Was this tool helpful?
Share Your Experience
Help others discover this tool!
Related tools
- Changelog GeneratorGenerate changelog from Git commit history
- npm to Yarn ConverterConvert npm commands and package-lock.json to Yarn equivalents
- Commit Message GeneratorGenerate conventional commit messages
- Git Branch Name GeneratorGenerate conventional Git branch names
- Merge Conflict ResolverVisualize and resolve Git merge conflicts
- Git Command GeneratorGenerate Git commands for common operations
They follow the same categories as the official Git documentation — Setup & Config, Getting Started, Basic Snapshotting, Branching & Merging, Sharing & Updating, Inspection & Comparison, and others. Use the category chips to view one section, or search to cut across all of them.
Yes. Each card has separate copy buttons — one for the command itself and one for the example when an example is provided. That way you can grab the bare command or a fully-formed example with real arguments, whichever you need.

