Git cartoons
Meet the chest of drawers
The whole idea of Git in one picture: a desk, a tray, a chest of drawers — and later a storage room at school.
In Git:
📌 Remember
working folder | the desk: your files |
staging area | the tray: the next commit |
commit | a drawer: one saved version |
repository | the chest (the .git folder) |
remote / origin | the storage room (server) |
Enable Git: build the chest (git init)
A folder only gets a chest when you ask for it. A paper is only tracked (saved by Git) once it has a Git sticker.
In Git:
📖 What do the two letters in git status --short mean?
Every line starts with two letters: XY 1st letter = the TRAY (staged) · 2nd letter = the DESK (changed, not staged yet). A dot “·” here means an empty place (a space). Files that are tracked and unchanged are not listed at all.
| letters | meaning | long git status shows it under |
|---|---|---|
| ?? | untracked A new paper with NO Git sticker. Git sees it but has never saved it — it is in no drawer until you git add it. | Untracked files |
| A· | added A new file, put on the tray. It goes into the next drawer. | Changes to be committed: new file |
| ·M | modified, not on the tray Changed on the desk only. The next drawer will NOT contain this change until you git add it. | Changes not staged for commit: modified |
| M· | modified, on the tray Changed and put on the tray: ready for the next drawer. | Changes to be committed: modified |
| AM | added, then changed again New file on the tray, and after git add you wrote more on the desk. The tray still holds the OLDER copy. | in BOTH sections |
| MM | on the tray, then changed again One change is on the tray AND a newer change is only on the desk. git add again to put the newest on the tray. | in BOTH sections |
| ·D | deleted, not on the tray You deleted the file on the desk. | Changes not staged: deleted |
Tip: first run git status — it explains everything in words. Use git status --short once the letters feel easy.
📌 Remember
git init | turn this folder into a repository (creates .git) |
git status | is this a repository? what is untracked? |
untracked | Git sees the file but has never saved it |
git status --short | short form: ?? = untracked |
git ls-files | list the tracked files |
git add: put it on the tray
add copies the paper onto the tray — and gives it a Git sticker for good.
In Git:
📖 What do the two letters in git status --short mean?
Every line starts with two letters: XY 1st letter = the TRAY (staged) · 2nd letter = the DESK (changed, not staged yet). A dot “·” here means an empty place (a space). Files that are tracked and unchanged are not listed at all.
| letters | meaning | long git status shows it under |
|---|---|---|
| ?? | untracked A new paper with NO Git sticker. Git sees it but has never saved it — it is in no drawer until you git add it. | Untracked files |
| A· | added A new file, put on the tray. It goes into the next drawer. | Changes to be committed: new file |
| ·M | modified, not on the tray Changed on the desk only. The next drawer will NOT contain this change until you git add it. | Changes not staged for commit: modified |
| M· | modified, on the tray Changed and put on the tray: ready for the next drawer. | Changes to be committed: modified |
| AM | added, then changed again New file on the tray, and after git add you wrote more on the desk. The tray still holds the OLDER copy. | in BOTH sections |
| MM | on the tray, then changed again One change is on the tray AND a newer change is only on the desk. git add again to put the newest on the tray. | in BOTH sections |
| ·D | deleted, not on the tray You deleted the file on the desk. | Changes not staged: deleted |
Tip: first run git status — it explains everything in words. Use git status --short once the letters feel easy.
📌 Remember
git add FILE | put one file on the tray (and track it) |
git add . | put every change in this folder on the tray |
A | added: a new file on the tray |
?? | untracked: not saved by Git at all |
Edit a file: what happens?
The tray holds a COPY. If you keep writing on the desk after git add, desk and tray are now different.
In Git:
📖 What do the two letters in git status --short mean?
Every line starts with two letters: XY 1st letter = the TRAY (staged) · 2nd letter = the DESK (changed, not staged yet). A dot “·” here means an empty place (a space). Files that are tracked and unchanged are not listed at all.
| letters | meaning | long git status shows it under |
|---|---|---|
| ?? | untracked A new paper with NO Git sticker. Git sees it but has never saved it — it is in no drawer until you git add it. | Untracked files |
| A· | added A new file, put on the tray. It goes into the next drawer. | Changes to be committed: new file |
| ·M | modified, not on the tray Changed on the desk only. The next drawer will NOT contain this change until you git add it. | Changes not staged for commit: modified |
| M· | modified, on the tray Changed and put on the tray: ready for the next drawer. | Changes to be committed: modified |
| AM | added, then changed again New file on the tray, and after git add you wrote more on the desk. The tray still holds the OLDER copy. | in BOTH sections |
| MM | on the tray, then changed again One change is on the tray AND a newer change is only on the desk. git add again to put the newest on the tray. | in BOTH sections |
| ·D | deleted, not on the tray You deleted the file on the desk. | Changes not staged: deleted |
Tip: first run git status — it explains everything in words. Use git status --short once the letters feel easy.
📌 Remember
git diff | desk vs tray: not yet added |
git diff --staged | tray vs last drawer: what the next commit will contain |
AM | added to the tray, then changed again on the desk |
git status: where is everything?
Your checklist before every step. Read it top to bottom: tray, then desk, then untracked.
In Git:
📖 What do the two letters in git status --short mean?
Every line starts with two letters: XY 1st letter = the TRAY (staged) · 2nd letter = the DESK (changed, not staged yet). A dot “·” here means an empty place (a space). Files that are tracked and unchanged are not listed at all.
| letters | meaning | long git status shows it under |
|---|---|---|
| ?? | untracked A new paper with NO Git sticker. Git sees it but has never saved it — it is in no drawer until you git add it. | Untracked files |
| A· | added A new file, put on the tray. It goes into the next drawer. | Changes to be committed: new file |
| ·M | modified, not on the tray Changed on the desk only. The next drawer will NOT contain this change until you git add it. | Changes not staged for commit: modified |
| M· | modified, on the tray Changed and put on the tray: ready for the next drawer. | Changes to be committed: modified |
| AM | added, then changed again New file on the tray, and after git add you wrote more on the desk. The tray still holds the OLDER copy. | in BOTH sections |
| MM | on the tray, then changed again One change is on the tray AND a newer change is only on the desk. git add again to put the newest on the tray. | in BOTH sections |
| ·D | deleted, not on the tray You deleted the file on the desk. | Changes not staged: deleted |
Tip: first run git status — it explains everything in words. Use git status --short once the letters feel easy.
📌 Remember
git status | the checklist in words: tray, desk, untracked |
git status --short | the same in two letters: 1st = tray, 2nd = desk |
git commit: the tray becomes a drawer
commit puts exactly what is on the TRAY into a new labelled drawer. Your desk is not touched.
In Git:
📌 Remember
git commit -m "msg" | tray → new drawer with a message |
git log --oneline | the drawer labels |
git show HEAD:FILE | read a file from the last drawer |
HEAD (📍) | where you are: the tag you follow |
Changed your mind? Add more, take back, erase
Until you commit, you decide what is on the tray — and you can throw away scribbles on your desk.
In Git:
📖 What do the two letters in git status --short mean?
Every line starts with two letters: XY 1st letter = the TRAY (staged) · 2nd letter = the DESK (changed, not staged yet). A dot “·” here means an empty place (a space). Files that are tracked and unchanged are not listed at all.
| letters | meaning | long git status shows it under |
|---|---|---|
| ?? | untracked A new paper with NO Git sticker. Git sees it but has never saved it — it is in no drawer until you git add it. | Untracked files |
| A· | added A new file, put on the tray. It goes into the next drawer. | Changes to be committed: new file |
| ·M | modified, not on the tray Changed on the desk only. The next drawer will NOT contain this change until you git add it. | Changes not staged for commit: modified |
| M· | modified, on the tray Changed and put on the tray: ready for the next drawer. | Changes to be committed: modified |
| AM | added, then changed again New file on the tray, and after git add you wrote more on the desk. The tray still holds the OLDER copy. | in BOTH sections |
| MM | on the tray, then changed again One change is on the tray AND a newer change is only on the desk. git add again to put the newest on the tray. | in BOTH sections |
| ·D | deleted, not on the tray You deleted the file on the desk. | Changes not staged: deleted |
Tip: first run git status — it explains everything in words. Use git status --short once the letters feel easy.
📌 Remember
git add FILE | again: stage the newest version |
git restore --staged FILE | take a file off the tray (keeps your file) |
git restore FILE | throw away desk changes (copy back from the drawer) |
M / M | 1st place = on the tray · 2nd place = only on the desk |
Commit again — and fix the last drawer
A second drawer. Forgot something? You can re-pack the LAST drawer before you share it.
In Git:
📌 Remember
git commit -m | another drawer on top |
git commit --amend | redo the last drawer (new id) — before pushing only |
--no-edit | keep the same message |
Where is it now?
Your papers are still on your desk. The drawers hold COPIES, safely inside the hidden .git folder.
In Git:
📌 Remember
ls | the desk: your files |
ls .git | the chest: the repository |
git ls-tree --name-only HEAD | files inside the last drawer |
git show --stat HEAD | open the last drawer |
git push: copies to the school storage room
Your drawers are only at home. push carries COPIES of them to the storage room (the server), so the team — and your future self — have them too.
In Git:
- ✅ your commits (drawers) that the server does not have yet
- ✅ the branch name (the server’s main moves to your newest commit)
- ❌ files you changed but did not commit
- ❌ what is only on the tray (staged)
- ❌ untracked files
So: add → commit → push. No commit, nothing to push.
📌 Remember
git remote add origin URL | write the server address in your address book |
git remote -v | show the address |
git ls-remote origin | what the server has (branches and ids) |
git push -u origin main | first push: send commits + link main to origin/main |
git push | every later push |
git branch -vv | which server branch each branch follows |
origin/main | your bookmark of the server’s main |
what travels | only COMMITS — not unsaved desk changes, not the tray |
fetch or pull? Look, or look and take
Leo added a drawer at school. FETCH = look through the window. PULL = look and carry it home onto your desk.
In Git:
🔍 fetch = look (safe any time) · 📦 pull = look + take (changes your files)
📌 Remember
git fetch | look: download, move origin/main, files untouched |
git log main..origin/main | what is new on the server |
git pull | look + take: fetch and merge into your branch |
behind / ahead | git status compares main with origin/main |
The daily loop: edit, re-edit, commit, push
What you do every day, start to finish — including editing again after git add.
In Git:
📖 What do the two letters in git status --short mean?
Every line starts with two letters: XY 1st letter = the TRAY (staged) · 2nd letter = the DESK (changed, not staged yet). A dot “·” here means an empty place (a space). Files that are tracked and unchanged are not listed at all.
| letters | meaning | long git status shows it under |
|---|---|---|
| ?? | untracked A new paper with NO Git sticker. Git sees it but has never saved it — it is in no drawer until you git add it. | Untracked files |
| A· | added A new file, put on the tray. It goes into the next drawer. | Changes to be committed: new file |
| ·M | modified, not on the tray Changed on the desk only. The next drawer will NOT contain this change until you git add it. | Changes not staged for commit: modified |
| M· | modified, on the tray Changed and put on the tray: ready for the next drawer. | Changes to be committed: modified |
| AM | added, then changed again New file on the tray, and after git add you wrote more on the desk. The tray still holds the OLDER copy. | in BOTH sections |
| MM | on the tray, then changed again One change is on the tray AND a newer change is only on the desk. git add again to put the newest on the tray. | in BOTH sections |
| ·D | deleted, not on the tray You deleted the file on the desk. | Changes not staged: deleted |
Tip: first run git status — it explains everything in words. Use git status --short once the letters feel easy.
🔁 edit → git status → git add → (edited again? git add again) → git commit → git push
📌 Remember
edit → git status | see what changed (then git status --short) |
git add | stage (again after more edits) |
git diff / --staged | check desk / tray |
git commit -m | save a drawer |
git push | share it |
Fix it before you push: amend and reset --soft
Until you push, your drawers are private — you may still re-pack the last one. After the push they are shared: then never rewrite, add a new drawer instead.
In Git:
🟢 Before push: amend · reset --soft · restore — all fine. 🔴 After push: never rewrite. New commit or git revert.
📌 Remember
git status | “ahead of origin/main” = not pushed yet = safe to fix |
git log origin/main..main | list your unpushed commits |
git commit --amend -m "msg" | fix the last label (new id) |
git add FILE + git commit --amend --no-edit | add a forgotten change to the last commit |
git reset --soft HEAD~1 | un-commit; the changes stay on the tray |
after a push | never amend: make a new commit, or git revert |
git reset --hard origin/main | throw away local commits and changes: back to the server’s version (careful!) |
Logs: read the labels, open drawers, search
git log reads the drawer labels. Options show the changes, or filter by date, person or file.
In Git:
📌 Remember
git log | full labels |
--oneline | short |
-p / -1 | with changes / only the newest |
--since / --until | by date (give a time) |
--author=NAME | by person |
-- FILE | by file |
--pretty=format:"…" | your own layout |
Get an old version back
Every drawer still holds all its papers. You can read an old copy — or put it back on your desk.
In Git:
📌 Remember
HEAD~N | N drawers below the newest |
git show HEAD~2:FILE | read an old version |
git restore --source=HEAD~2 FILE | put an old version on the desk |
git restore FILE | back to the newest |
Branches: name tags on drawers
A branch is only a NAME TAG stuck on a drawer. New drawers go wherever the tag you follow (📍 HEAD) points — and that tag moves up with them.
In Git:
📖 How to read the graph: what do * and | mean?
* = one commit (one drawer)| = a line of history, going down to OLDER commits\ / = two lines split apart or join togetherNewest is at the TOP. Each * is on the line (column) its branch uses: here the left line = main, the right line = sports.
| # | the real output | what it means |
|---|---|---|
| 1 | * d9a6948 (HEAD -> main, tag: v1.0) Merge sports page | NEWEST commit (d9a6948): a MERGE. It joins the two lines you see below it. The branch main and the tag v1.0 point here, and HEAD = you are on main. |
| 2 | |\ | The line SPLITS into two. Why? The merge above has two parents: the left line is main, the right line is sports. |
| 3 | | * 3430c2d (sports) Add chess result | RIGHT line (sports): Leo’s newest commit 3430c2d. The sports name tag is here. The “|” on the left only means: main’s line continues past it. |
| 4 | | * 00dd761 Add football score | RIGHT line (sports): Leo’s first commit 00dd761, one step older. |
| 5 | * | f530647 Add weekly forecast | LEFT line (main): Maya’s commit f530647, made while Leo was working on sports. The “|” on the right: sports’ line continues past it. |
| 6 | |/ | The right line JOINS the left one again: this is where sports started (it grew out of the commit just below). |
| 7 | * d1781a3 (origin/main, origin/HEAD) Update the weather report | The commit where both lines began (d1781a3). origin/main (the server’s main) is still here — nothing above it is pushed yet. |
The story, read from the BOTTOM up:
- Everybody starts from d1781a3 (row 7).
- Leo makes the sports branch and adds two commits: 00dd761, then 3430c2d (rows 4 and 3).
- At the same time Maya adds f530647 on main (row 5).
- Maya merges sports into main: d9a6948 (row 1) joins both lines. Done — main now contains everything.
📌 Remember
branch | a name tag on a commit; it moves up when you commit on it |
HEAD (📍) | the branch you are on |
git branch | list (* = current) |
git branch NAME | create, stay where you are |
git switch NAME | go to a branch (the desk changes to match) |
git switch -c NAME | create + go |
git checkout -b NAME | the same, older spelling |
git branch -d NAME | delete the tag (merged work only) |
git log --oneline --graph --all --decorate | the map of all branches |
Pull request: ask the teacher to merge it
You push your branch, then ASK on the server: “please check my comics and put them into main”. That request is a pull request.
In Git:
📌 Remember
git push -u origin BRANCH | publish your branch |
pull request | on the server’s web page: “please merge BRANCH into main” |
review | more commits + git push update it |
git switch main + git pull | get the merged result |
git fetch --prune | forget branches deleted on the server |
git branch -d BRANCH | remove your old tag |
Log power tools: graphs, filters, formats
Maya’s practice copy now has a sports branch (Leo), a merge and a v1.0 tag. Time to read history like a pro.
In Git:
📖 How to read the graph: what do * and | mean?
* = one commit (one drawer)| = a line of history, going down to OLDER commits\ / = two lines split apart or join togetherNewest is at the TOP. Each * is on the line (column) its branch uses: here the left line = main, the right line = sports.
| # | the real output | what it means |
|---|---|---|
| 1 | * d9a6948 (HEAD -> main, tag: v1.0) Merge sports page | NEWEST commit (d9a6948): a MERGE. It joins the two lines you see below it. The branch main and the tag v1.0 point here, and HEAD = you are on main. |
| 2 | |\ | The line SPLITS into two. Why? The merge above has two parents: the left line is main, the right line is sports. |
| 3 | | * 3430c2d (sports) Add chess result | RIGHT line (sports): Leo’s newest commit 3430c2d. The sports name tag is here. The “|” on the left only means: main’s line continues past it. |
| 4 | | * 00dd761 Add football score | RIGHT line (sports): Leo’s first commit 00dd761, one step older. |
| 5 | * | f530647 Add weekly forecast | LEFT line (main): Maya’s commit f530647, made while Leo was working on sports. The “|” on the right: sports’ line continues past it. |
| 6 | |/ | The right line JOINS the left one again: this is where sports started (it grew out of the commit just below). |
| 7 | * d1781a3 (origin/main, origin/HEAD) Update the weather report | The commit where both lines began (d1781a3). origin/main (the server’s main) is still here — nothing above it is pushed yet. |
The story, read from the BOTTOM up:
- Everybody starts from d1781a3 (row 7).
- Leo makes the sports branch and adds two commits: 00dd761, then 3430c2d (rows 4 and 3).
- At the same time Maya adds f530647 on main (row 5).
- Maya merges sports into main: d9a6948 (row 1) joins both lines. Done — main now contains everything.
📌 Remember
--oneline --graph --all --decorate | the map of all branches (make it an alias: git lg) |
-N | only N commits |
--author= / --grep= / -S | by person / by message / by changed text |
--after= --before= | by date (give a time) |
-- FILE | one file |
--merges / --no-merges / --first-parent | merge commits / without them / main line only |
A..B | in B but not in A |
--stat / --name-status / -p | files + counts / file list / full changes |
--pretty=format:"%h %an %ad %s" | your own layout |
--reverse | oldest first |
git shortlog -sn | commits per person |
git blame FILE | who wrote each line |