Git
The undo button for your career.
▶ the lesson · narrated sketch video · tap for sound
the intro
Git is version control: a time machine for your code. Commit to save a checkpoint, branch to explore an idea safely, merge when it works, push to share. Every bug becomes recoverable, and every experiment becomes cheap.
the sample
the sacred daily ritual
git add . git commit -m "fix stuff" git push # friday deploy, let’s go 😎
fun fact ✦
Git was built in ~10 days by the Linux creator after a licensing fight. Spite-driven development.
the docs
the deep dive
the ideas behind the video — concepts, diagrams, a walkthrough and the traps to avoid
Git does not store diffs of your files — it stores snapshots. Every commit is a full picture of the project (with identical parts shared behind the scenes), and a branch is just a sticky note pointing at one snapshot. Once you see commits as a graph of snapshots, merge, rebase, and reset stop being spells and become pointer moves.
commits are snapshots, branches are sticky notes
key terms
commit
An immutable snapshot of the project, addressed by a hash. Change anything inside it and the hash changes.
git commit -m "add login"staging area
The draft of your next commit. You pick changes with add, then commit records exactly what was staged.
git add -pHEAD
A pointer to where you are right now — usually the tip of your current branch.
detached HEAD = no branchreflog
A private journal of every move HEAD made. Deleted a branch by mistake? The commit is still in here for weeks.
git refloghow it works
- 1Check before you act
Run git status every time you sit down and every time you feel lost. It names your branch and exactly what changed.
- 2Stage one idea at a time
git add -p walks you through changes hunk by hunk. Small, single-purpose commits make reviews and reverts painless.
- 3Commit with a why
The message should say why the change exists, not restate the diff. Future you at 2 a.m. is the audience.
- 4Sync before you push
git pull --rebase replays your work on top of the latest main. Pushing a stale branch is how surprise merge conflicts are born.
the code, explained
the daily loop, done properly
side by side
merge
- history stays exactly as happened
- one extra merge commit
- safe on shared branches
- graph shows real branching
rebase
- replays commits on the target
- linear, easy-to-read history
- never on shared branches
- conflicts handled per commit
Git remembers everything you commit, forever. Deleting a file in a later commit does not scrub it from history — anyone can check out yesterday. If a secret hits a commit, rotate the credential first; rewriting history is cleanup, not security.
quick answers
I committed to the wrong branch. Now what?
If it is unpushed: git reset --soft HEAD~1, switch to the right branch, commit again. If pushed and shared: cherry-pick it over and revert the original.
How do I undo my last commit?
git reset --soft HEAD~1 keeps the changes staged, --hard throws them away. If the commit was already pushed to others, use revert instead.
Why is my repo so big?
History keeps every version of every file. Large binaries are the usual culprit — move assets to Git LFS and the clone shrinks dramatically.
quick hits about Git
short answers · interviews, tips, trivia & hidden gems
Merge or rebase?watch ↗
Reset vs revert?watch ↗
Conflicts decodedwatch ↗
What never goes in gitwatch ↗
Type less with aliaseswatch ↗
One commit = one ideawatch ↗
Commits are never truly lostwatch ↗
Binary-search the bugwatch ↗
Checks before every commitwatch ↗
Git is British slangwatch ↗