Cheatsheet Format: WebPages: 1Sections: 4
Git Commands Cheatsheet
Everyday Git commands for branching, rebasing, recovering work and keeping history clean.
Abhishek Sharma 2026-08-02 Tools & Workflow / Git
Quick reference
4 sections · 13 entries, designed for fast scanning.
Daily flow
4 entries| Name | Usage |
|---|---|
| git switch -c | git switch -c feature/nav Create and move to a branch in one step. |
| git add -p | git add -p Stage hunks interactively to keep commits focused. |
| git commit | git commit -m "feat: add responsive nav" |
| git push | git push -u origin HEAD Publish the branch and set upstream tracking. |
Inspecting history
3 entries| Name | Usage |
|---|---|
| git log | git log --oneline --graph --decorate -20 |
| git diff | git diff --stat origin/main...HEAD Preview everything your branch adds before opening a PR. |
| git blame | git blame -L 20,40 src/app.ts |
Recovering work
3 entries| Name | Usage |
|---|---|
| git reflog | git reflog Find commits after a reset, rebase or detached HEAD. |
| git restore | git restore --source=HEAD~1 path/to/file |
| git cherry-pick | git cherry-pick <sha> |
Undo safely
3 entries| Name | Usage |
|---|---|
| Soft reset | git reset --soft HEAD~1 Drop the commit but keep changes staged. |
| Revert | git revert <sha> Create an inverse commit on shared branches. |
| Stash | git stash push -m "wip: nav" |
How to use this sheet
Pin this reference next to your terminal. Commands are grouped by the job you are trying to do, not alphabetically.
Want more like this?
Browse the full cheatsheets library, organised by topic.
Related learning
Cheatsheet
JavaScript DOM Cheatsheet
The selectors, traversal methods, events and mutation APIs you actually use, on one printable page.
Programming / JavaScript
JavaScriptDOM
Web