Git Cheatsheet
Searchable interactive Git command reference organized by workflow - branching, merging, rebasing, and more.
Git Cheatsheet tool
Example
Input: Search Commands: stash
Result: 7 commands found: git stash, stash pop, stash list, stash drop, stash apply, stash show and stash branch <name>, each with an example
The search matches command names, descriptions, examples, flags and categories, so a topic word finds the whole related group.
Ways to Undo Changes in Git
| Command | What it does |
|---|---|
| git restore <file> | Discards unstaged changes to a file |
| git reset HEAD <file> | Unstages a file, keeping its changes |
| git reset --soft HEAD~1 | Removes the last commit, changes stay staged |
| git reset --mixed HEAD~1 | Removes the last commit, changes stay in files but unstaged |
| git reset --hard HEAD~1 | Removes the last commit and discards its changes |
| git revert <commit> | Adds a new commit that undoes an old one |
| git clean -fd | Deletes untracked files and folders |
Based on the Undoing Changes entries in this cheatsheet.
- Browse commands by workflow section (setup, snapshotting, branching and merging, remotes, history, stashing, undoing, advanced), expanding or collapsing each section with its header.
- Type a keyword such as "reset", "stash", or "--amend" into the search box to filter commands by name, description, example, or flag.
- Click on any command row to expand its description, a practical usage example, and commonly used flags.
- Copy the example command you need using the copy button next to it.
- Open the Advanced section for less common operations like bisect, submodules, worktrees, reflog, and rebase --onto.
Git Commands Grouped by Task
This Git cheatsheet lists 56 common commands grouped by what you are trying to do, from setting up a repository to undoing a mistake. Each entry has a short explanation, a copyable example and the flags people use most. Commands sit in eight sections. They run from Setup and Config and Basic Snapshotting through Branching and Merging, Sharing and Updating, and Inspection and Comparison, to Stashing, Undoing Changes and Advanced. Each section can be collapsed. Click a row to see its example and common flags, copy the example with one click, and then swap in your own branch name or commit ID.
The search box filters as you type. It looks at command names, descriptions, examples, flags and section names. Searching stash lists all seven stash commands, and searching --amend finds git commit. That helps when you know what you want to do but not the exact command.
Read the Undoing Changes section with care. The commands look alike but behave very differently, as the table shows. git reset --hard and git clean -fd throw away uncommitted work that Git cannot bring back, so run git status first, or git clean -n to preview. If a commit seems lost after a reset, git reflog in the Advanced section usually still knows where it is. For regular expressions, see the Regex Cheatsheet.
Sources
Frequently Asked Questions
Related Tools
Regex Cheatsheet
Interactive regex syntax reference with descriptions, examples, and a try-it-live tester for each pattern.
DevOps ToolsDocker Run to Docker Compose Converter
Convert docker run commands to docker-compose.yml format with proper YAML structure and service configuration.
DevOps ToolsCrontab Generator
Visually build cron expressions with dropdowns, see human-readable descriptions, and preview the next 5 run times.
DevOps Tools