
Programming cheat sheet
The Git Cheat Sheet: Commands, Undo Table, and Rescue Playbook
A copy-paste Git reference organized by the moment you need it, with an undo table that tells you what is safe on a shared branch.
Stop re-googling the same Git commands. This cheat sheet covers setup, the daily commit loop, branching, rebasing, and the part everyone actually needs: a searchable undo table that tells you which fix is safe on a shared branch and which will rewrite your teammates' history. Includes a step-by-step reflog walkthrough for recovering lost commits, power tools like bisect and worktree, useful aliases, and a pre-push checklist. Written for working developers and readable on your phone.
A living reference, not a download. Buy once and every update is included. It's currently on version 1, and you read it in your account, always current.
- Sections
- 8
- Code samples
- 4
- Tables
- 5
Outcomes
What you will be able to do
- Find the exact Git command for the situation in front of you in seconds
- Undo a commit, a merge, or a bad push without making things worse
- Know which fixes are safe on a shared branch and which rewrite history
- Recover work you thought was lost using the reflog
- Keep a clean, reviewable history with focused commits and tidy rebases
Is this for you?
Made for
- Developers who use Git daily but still copy commands from Stack Overflow
- Bootcamp graduates and juniors starting on a team workflow
- Self-taught developers who learned commit and push but not rebase or reflog
Probably not for
- Anyone looking for a deep explanation of how Git stores objects internally
- Teams that need a GUI-only workflow with no command line
Free preview
Read a piece before you buy
Git has hundreds of commands, but a working developer uses about thirty of them. This sheet is those thirty, grouped by the moment you reach for them: setting up, the daily loop, branching, undoing mistakes, and rescuing work you thought was gone.
Every command is copy-paste ready. The undo table tells you which fixes are safe on a shared branch and which ones will rewrite history for your teammates.
One-time setup
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git config --global init.defaultBranch main
git config --global push.autoSetupRemote true
git config --global pull.rebase true
git config --global rerere.enabled trueRun once per machine. These settings remove the most common day-one annoyances.
The daily loop
| git status -sb | Short status with the branch and ahead/behind counts |
| git add -p | Stage changes hunk by hunk so each commit stays focused |
| git diff | Show unstaged changes |
| git diff --staged | Show exactly what the next commit will contain |
| git commit -m "message" | Commit what is staged |
| git commit --amend --no-edit | Fold currently staged changes into the last commit |
| git log --oneline --graph --decorate -20 | Compact visual history of the last 20 commits |
| git stash push -u -m "wip" | Shelve all changes, including untracked files, with a label |
| git stash pop | Reapply the most recent stash and drop it |
| git fetch --prune | Download remote changes and remove deleted remote branches |
| git pull | Fetch and integrate remote changes (rebases if configured above) |
| git push | Upload your commits to the tracked remote branch |
12 of 12 rows
Questions, answered
Does this work with GitHub, GitLab, and Bitbucket?
Yes. Everything here is plain Git, so it works with any host.
Which Git version do I need?
Git 2.23 or newer for switch and restore. Git 2.37 or newer for push.autoSetupRemote.
Can I read it on my phone?
Yes. The guide is built for small screens, and the tables and code blocks scroll cleanly.
A clear reference, ready when you need it.
Purchase unlocks the complete guide in your account, with every future update included. You'll create or sign in to your account at checkout so your access stays attached to you.