Git cartoons

🖊️ desk = working folder📥 tray = staging area🗄️ chest = repository🗃️ drawer = commit🏷️ name tag = branch📍 = HEAD🏫 storage room = server🪟 window = fetch
1

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 folderthe desk: your files
staging areathe tray: the next commit
commita drawer: one saved version
repositorythe chest (the .git folder)
remote / originthe storage room (server)

📘 The same in the courseEpisode 2 →

2

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.

lettersmeaninglong 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
·Mmodified, 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
AMadded, 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
MMon 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
·Ddeleted, 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 initturn this folder into a repository (creates .git)
git statusis this a repository? what is untracked?
untrackedGit sees the file but has never saved it
git status --shortshort form: ?? = untracked
git ls-fileslist the tracked files

← Episode 1📘 The same in the courseEpisode 3 →

3

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.

lettersmeaninglong 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
·Mmodified, 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
AMadded, 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
MMon 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
·Ddeleted, 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 FILEput 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

← Episode 2📘 The same in the courseEpisode 4 →

4

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.

lettersmeaninglong 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
·Mmodified, 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
AMadded, 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
MMon 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
·Ddeleted, 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 diffdesk vs tray: not yet added
git diff --stagedtray vs last drawer: what the next commit will contain
AMadded to the tray, then changed again on the desk

← Episode 3📘 The same in the courseEpisode 5 →

5

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.

lettersmeaninglong 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
·Mmodified, 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
AMadded, 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
MMon 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
·Ddeleted, 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 statusthe checklist in words: tray, desk, untracked
git status --shortthe same in two letters: 1st = tray, 2nd = desk

← Episode 4📘 The same in the courseEpisode 6 →

6

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 --onelinethe drawer labels
git show HEAD:FILEread a file from the last drawer
HEAD (📍)where you are: the tag you follow

← Episode 5📘 The same in the courseEpisode 7 →

7

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.

lettersmeaninglong 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
·Mmodified, 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
AMadded, 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
MMon 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
·Ddeleted, 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 FILEagain: stage the newest version
git restore --staged FILEtake a file off the tray (keeps your file)
git restore FILEthrow away desk changes (copy back from the drawer)
M / M1st place = on the tray · 2nd place = only on the desk

← Episode 6📘 The same in the courseEpisode 8 →

8

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 -manother drawer on top
git commit --amendredo the last drawer (new id) — before pushing only
--no-editkeep the same message

← Episode 7📘 The same in the courseEpisode 9 →

9

Where is it now?

Your papers are still on your desk. The drawers hold COPIES, safely inside the hidden .git folder.

In Git:

📌 Remember

lsthe desk: your files
ls .gitthe chest: the repository
git ls-tree --name-only HEADfiles inside the last drawer
git show --stat HEADopen the last drawer

← Episode 8📘 The same in the courseEpisode 10 →

10

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:

What git push sends
  • ✅ 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 URLwrite the server address in your address book
git remote -vshow the address
git ls-remote originwhat the server has (branches and ids)
git push -u origin mainfirst push: send commits + link main to origin/main
git pushevery later push
git branch -vvwhich server branch each branch follows
origin/mainyour bookmark of the server’s main
what travelsonly COMMITS — not unsaved desk changes, not the tray

← Episode 9📘 The same in the courseEpisode 11 →

11

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 fetchlook: download, move origin/main, files untouched
git log main..origin/mainwhat is new on the server
git pulllook + take: fetch and merge into your branch
behind / aheadgit status compares main with origin/main

← Episode 10📘 The same in the courseEpisode 12 →

12

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.

lettersmeaninglong 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
·Mmodified, 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
AMadded, 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
MMon 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
·Ddeleted, 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 statussee what changed (then git status --short)
git addstage (again after more edits)
git diff / --stagedcheck desk / tray
git commit -msave a drawer
git pushshare it

← Episode 11📘 The same in the courseEpisode 13 →

13

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..mainlist your unpushed commits
git commit --amend -m "msg"fix the last label (new id)
git add FILE + git commit --amend --no-editadd a forgotten change to the last commit
git reset --soft HEAD~1un-commit; the changes stay on the tray
after a pushnever amend: make a new commit, or git revert
git reset --hard origin/mainthrow away local commits and changes: back to the server’s version (careful!)

← Episode 12📘 The same in the courseEpisode 14 →

14

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 logfull labels
--onelineshort
-p / -1with changes / only the newest
--since / --untilby date (give a time)
--author=NAMEby person
-- FILEby file
--pretty=format:"…"your own layout

← Episode 13📘 The same in the courseEpisode 15 →

15

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~NN drawers below the newest
git show HEAD~2:FILEread an old version
git restore --source=HEAD~2 FILEput an old version on the desk
git restore FILEback to the newest

← Episode 14📘 The same in the courseEpisode 16 →

16

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 together

Newest is at the TOP. Each * is on the line (column) its branch uses: here the left line = main, the right line = sports.

#the real outputwhat 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:

  1. Everybody starts from d1781a3 (row 7).
  2. Leo makes the sports branch and adds two commits: 00dd761, then 3430c2d (rows 4 and 3).
  3. At the same time Maya adds f530647 on main (row 5).
  4. Maya merges sports into main: d9a6948 (row 1) joins both lines. Done — main now contains everything.

📌 Remember

brancha name tag on a commit; it moves up when you commit on it
HEAD (📍)the branch you are on
git branchlist (* = current)
git branch NAMEcreate, stay where you are
git switch NAMEgo to a branch (the desk changes to match)
git switch -c NAMEcreate + go
git checkout -b NAMEthe same, older spelling
git branch -d NAMEdelete the tag (merged work only)
git log --oneline --graph --all --decoratethe map of all branches

← Episode 15📘 The same in the courseEpisode 17 →

17

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 BRANCHpublish your branch
pull requeston the server’s web page: “please merge BRANCH into main”
reviewmore commits + git push update it
git switch main + git pullget the merged result
git fetch --pruneforget branches deleted on the server
git branch -d BRANCHremove your old tag

← Episode 16📘 The same in the courseEpisode 18 →

18

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 together

Newest is at the TOP. Each * is on the line (column) its branch uses: here the left line = main, the right line = sports.

#the real outputwhat 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:

  1. Everybody starts from d1781a3 (row 7).
  2. Leo makes the sports branch and adds two commits: 00dd761, then 3430c2d (rows 4 and 3).
  3. At the same time Maya adds f530647 on main (row 5).
  4. Maya merges sports into main: d9a6948 (row 1) joins both lines. Done — main now contains everything.

📌 Remember

--oneline --graph --all --decoratethe map of all branches (make it an alias: git lg)
-Nonly N commits
--author= / --grep= / -Sby person / by message / by changed text
--after= --before=by date (give a time)
-- FILEone file
--merges / --no-merges / --first-parentmerge commits / without them / main line only
A..Bin B but not in A
--stat / --name-status / -pfiles + counts / file list / full changes
--pretty=format:"%h %an %ad %s"your own layout
--reverseoldest first
git shortlog -sncommits per person
git blame FILEwho wrote each line

← Episode 17📘 The same in the courseStart the course →