Git Cheat Sheet
Complete interactive reference of Git commands with search and copy.
62 commands across 8 categories
git initInitialize a new Git repository in the current directory
git clone <url>Clone a remote repository to your local machine
git config --global user.name "<name>"Set your global Git username
git config --global user.email "<email>"Set your global Git email address
git config --listList all Git configuration settings
git statusShow the current status of the working directory and staging area
git add <file>Stage a specific file for the next commit
git add .Stage all changes in the current directory for the next commit
git commit -m "<message>"Commit staged changes with a descriptive message
git commit -am "<message>"Stage all tracked files and commit in one step
git diffShow unstaged changes between working directory and staging area
git diff --stagedShow changes that are staged for the next commit
git rm <file>Remove a file from the working directory and stage the removal
git mv <old> <new>Rename or move a file and stage the change
git branchList all local branches
git branch <name>Create a new branch with the given name
git branch -d <name>Delete a local branch (safe delete)
git branch -D <name>Force delete a local branch
git checkout <branch>Switch to a different branch
git checkout -b <name>Create and switch to a new branch in one step
git switch <branch>Switch to a branch (modern alternative to checkout)
git switch -c <name>Create and switch to a new branch (modern)
git branch -m <old> <new>Rename a branch
git merge <branch>Merge the specified branch into the current branch
git merge --no-ff <branch>Merge with a merge commit (no fast-forward)
git merge --abortAbort the current merge and restore the previous state
git cherry-pick <commit>Apply changes from a specific commit onto the current branch
git rebase <branch>Rebase the current branch onto the specified branch
git rebase -i <commit>Interactive rebase to edit, squash, or reorder commits
git remote -vList all remote repositories with their URLs
git remote add <name> <url>Add a new remote repository
git remote remove <name>Remove a remote repository
git fetch <remote>Download objects and refs from a remote repository
git pull <remote> <branch>Fetch and merge changes from a remote branch
git push <remote> <branch>Push local commits to a remote repository
git push -u origin <branch>Push and set upstream tracking for a new branch
git push --forceForce push, overwriting remote history (use with caution)
git stashTemporarily store modified tracked files
git stash listList all stashed changes
git stash popApply the most recent stash and remove it from the stash list
git stash applyApply the most recent stash without removing it
git stash dropDiscard the most recent stash
git stash clearRemove all stashed entries
git stash branch <name>Create a branch from a stash
git logShow the full commit history
git log --onelineShow commit history in compact one-line format
git log --graphShow commit history as an ASCII graph
git log -n <count>Show only the last N commits
git log --author="<name>"Filter commits by author
git log --since="<date>"Show commits since a specific date
git shortlogShow commit counts by author
git show <commit>Show details of a specific commit
git blame <file>Show who last modified each line of a file
git reset <file>Unstage a file while keeping the changes
git reset --soft <commit>Reset to a commit, keeping changes staged
git reset --mixed <commit>Reset to a commit, keeping changes unstaged
git reset --hard <commit>Reset to a commit, discarding all changes (dangerous)
git revert <commit>Create a new commit that undoes a previous commit
git checkout -- <file>Discard changes in a working directory file
git restore <file>Restore a file in the working directory (modern)
git clean -fdRemove untracked files and directories
git reflogShow a log of where HEAD has been (recovery tool)
Introduction
Git has over 150 commands and thousands of flag combinations, yet most developers use only a dozen on a daily basis and forget the rest when they need them. Rebasing interactively, amending the last commit, bisecting to find a regression, or resetting to a specific ref — these operations come up just often enough that you cannot remember the exact syntax but too rarely to build muscle memory. A Git cheat sheet organizes the most essential commands into searchable categories so you can find the right incantation in seconds instead of digging through man pages or Stack Overflow.
What Is Git Cheat Sheet?
A Git cheat sheet is a categorized reference of the most frequently used Git commands, organized by workflow stage: setup and configuration, repository initialization, staging and commits, branching and merging, remote operations, inspection and comparison, undoing changes, and advanced operations like bisect, cherry-pick, and reflog. Each command entry includes the full syntax, a one-line description of what it does, and the most common flag combinations.
The cheat sheet goes beyond raw command listings by explaining the difference between commonly confused commands. "git reset --soft" vs "git reset --mixed" vs "git reset --hard" is explained with a visual diagram showing what happens to the HEAD pointer, the staging area, and the working directory in each case. "git merge" vs "git rebase" is explained in terms of commit graph topology, and "git revert" vs "git reset" is clarified with guidance on when each is appropriate for a shared vs private branch.
Each command includes a "danger level" indicator — green for safe read-only operations like git log and git diff, yellow for operations that modify history locally like git commit --amend, and red for operations that rewrite shared history like git push --force. This visual cue helps developers avoid destructive commands on shared branches while feeling confident using them on personal feature branches. The cheat sheet also provides copy-ready command snippets that you can paste directly into your terminal.
Git Cheat Sheet Examples
| Input | Output |
|---|---|
| Search: "undo last commit" | git reset --soft HEAD~1 — undoes commit, keeps changes staged |
| Search: "interactive rebase" | git rebase -i HEAD~3 — edit last 3 commits (pick, squash, reword) |
| Browse: "Branching" category | git branch, git checkout -b, git merge, git branch -d, and 8 more |
Key Features of Git Cheat Sheet
- 80+ essential Git commands organized into 10 workflow categories for quick navigation
- Keyword search across command names, descriptions, and common use-case phrases
- Comparison explanations for confused command pairs: reset vs revert, merge vs rebase, fetch vs pull
- Danger-level color indicators showing which commands are safe, caution-worthy, or destructive
- Common flag combinations for each command so you do not have to look up the man page
- One-click copy of any command ready to paste into a terminal session
- Visual diagrams explaining HEAD, staging area, and working directory state changes for reset and checkout
How It Works
Browse Commands by Category
Navigate through organized sections covering setup, branching, merging, remote operations, stashing, logging, undoing changes, and many more. Each category groups related commands together so you can quickly find what you need without scanning an alphabetical list of dozens of commands.
Search by Keyword or Task
Type a keyword like 'undo' or 'branch' into the search bar to instantly filter the command list to relevant entries. The search matches against command names, flags, and descriptions, so you can find a command even if you only remember what it does rather than what it is called.
Copy Commands with One Click
Each command entry has a copy button that sends the git command and its flags to your clipboard. Paste it directly into your terminal, substituting your branch names or file paths as needed. This eliminates the risk of typos that can cause unintended repository changes.
Who Uses This
Junior Developers
looking up Git commands during their first months on the job when they need to rebase a branch or stash changes but have not yet memorized the exact flags and argument order
Tech Leads
sharing the cheat sheet link with new team members during onboarding so they can self-serve answers to common Git questions instead of interrupting senior developers during focused work
Open Source Contributors
quickly referencing less common Git operations like cherry-pick and bisect that they only need occasionally when maintaining multiple forks and feature branches across different repositories
Related Tools
Chmod Calculator
Calculate Linux file permission codes visually
Try itUtilityCron Expression Generator
Build cron schedules with human-readable summaries
Try itUtilityHTTP Status Codes
Searchable reference of HTTP response status codes
Try itUtilityFake Data Generator
Generate realistic test data for QA and development
Try it