The Git Cheat Sheet
Everyday commands.
Here are the commands you learned, collected in one place. Pause on these screens, or take a screenshot, and keep them nearby while you practise.

- Every command, in one place
- Pause or screenshot
- Keep it nearby
Every day
These are the everyday commands. Status, to see what's going on. Add, to stage. Commit, to save a snapshot. Log, to read history. And diff, to see exact changes.
| Command | What it does |
|---|---|
| git status | what's going on |
| git add <file> / . | stage changes |
| git commit -m "msg" | save a snapshot |
| git log --oneline --graph | read history |
| git diff / --staged | see exact changes |
Branches and GitHub
Next, branches and GitHub. Switch dash c creates a branch. Merge brings one into another. Clone, pull and push talk to GitHub. And remote add connects a repository to it.
| Command | What it does |
|---|---|
| git switch -c <name> | create and switch |
| git merge <branch> | combine branches |
| git clone <url> | copy a repository |
| git pull / git push | download / upload |
| git remote add origin <url> | connect to GitHub |
Undo and rescue
And the undo commands. Restore discards edits, or unstages with dash dash staged. Amend fixes the last commit. Revert undoes a shared commit. Reset moves back local commits. Stash shelves work. And reflog rescues almost anything.
| Command | What it does |
|---|---|
| git restore [--staged] <file> | discard or unstage |
| git commit --amend | fix the last commit |
| git revert <hash> | undo, safely |
| git reset [--soft|--hard] | move back, local only |
| git stash / git reflog | shelve / rescue |
Summary
Status, add, commit, branch, merge, push, pull, and the undo commands. That's Git. Next, where to go from here.
Key takeaways- Everyday: status, add, commit
- Teamwork: branch, PR, pull, push
- Rescue: restore, revert, reflog