006
LVL 00 — CADET PILOT SESSION 006 DAY 6

NEVER LOSE YOUR WORK

SYS.SCENARIO
🏢 The senior dev tells a horror story over coffee: "Two years ago, an intern spent three days building a feature. Then they accidentally saved over their file with an empty one. No backup. Started from scratch. Three days gone." He pauses. "That's why we use Git. It remembers every change you've ever made. Every. Single. One."
CONCEPTS.UNLOCKED
📜
Version Control
Tracking changes to files over time. Undo mistakes, collaborate without conflicts, keep a history of every decision ever made.
⚙↔☁
Git vs GitHub
Git is the tool (runs locally on your machine). GitHub is the hosting platform (stores repos in the cloud). Git works without GitHub.
①②③
Three Stages
Working directory (edit files) → Staging area (prepare changes) → Repository (committed snapshots stored permanently in .git).
$
Core Commands
git init, git status, git add, git commit -m, git log, git diff. Six commands — that's your daily toolkit.
🚫
.gitignore
Files Git should never track: node_modules/, .env, .DS_Store, *.log, dist/. Secrets and generated files stay out of history.
Commit Messages
Imperative mood, descriptive: "Add user upload validation" not "changes" or "fixed stuff". Your future self reads these.
HANDS-ON.TASKS
01
Create Your First Repo
mkdir ~/git-practice && cd ~/git-practice git init git status # "No commits yet"
git init creates a hidden .git/ directory. That's where Git stores everything. Delete .git/ and the repo is gone — the files remain, but the history vanishes.
02
The Three-Stage Flow

Watch how a file moves through all three stages:

echo "# My First Repo" > README.md git status # Untracked file (red) git add README.md git status # Staged (green) git commit -m "Add initial README" git status # Clean — nothing to commit git log # Your first commit!

Now make 5 more files and 5 meaningful commits. Check git status at EVERY step.

03
See Changes with git diff

Always inspect changes before staging:

echo "New content" >> README.md git diff # See the change (red/green) git add README.md git diff --staged # See what's staged git commit -m "Update README with new content"
git diff shows what changed in your working directory. git diff --staged shows what's about to be committed. Always review before committing.
04
Undo a Mistake

Destroy a file on purpose, then restore it:

echo "OOPS I DELETED EVERYTHING" > README.md cat README.md # It's ruined! git checkout -- README.md # Restored! cat README.md # Back to last commit
git checkout -- restores a file to the last committed version. This is your safety net. As long as you committed, you can always go back.
05
Explore History
git log --oneline # Compact view git log --oneline --graph # With branch visualization git show <commit-hash> # See exactly what changed

Copy a commit hash from git log --oneline and inspect it with git show.

06
Create .gitignore

Create a .gitignore file with standard ignores:

node_modules/ .env .DS_Store *.log dist/

Commit it: git add .gitignore && git commit -m "Add .gitignore"

07
Commit Message Discipline

Make 10 commits with good messages. Imperative mood, descriptive:

✅ Good❌ Bad
Add user upload validationchanges
Fix brightness slider overflow at max valuefixed stuff
Remove unused CSS from toolbarwip
Update README installation stepsupdate
CS.DEEP-DIVE

SHA-1 Cryptographic Hashes.

Git uses SHA-1 hashes to identify every commit. The hash a1b2c3d4e5... is a 40-character fingerprint of your ENTIRE project at that moment.

// Change one character in one file
// → completely different hash.

commit a1b2c3d  "Add filter module"
commit f7e8d9c  "Fix slider overflow"
commit 3k4l5m6  "Update README"

// The same hash concept powers:

Blockchain      → each block hashes the previous
Passwords       → bcrypt hashes stored, never plaintext
Downloads       → checksums verify file integrity
Digital sigs    → prove authorship cryptographically

// Hash functions are one of the most important
// tools in computer science.
"Git Time Machine"
[A] Make 10 commits that tell a story — a mini text adventure. Each commit adds the next chapter.
[B] Use git log to read the story. Use git show to read any chapter.
[C] Use git diff <hash1> <hash2> to see what changed between chapters.
REF.MATERIAL
VIDEO
Corey Schafer
30-minute no-nonsense walkthrough of init, add, commit, diff, log, and .gitignore. The essentials, nothing more.
GITBEGINNER
VIDEO
Colt Steele
Speed run through the core Git workflow. Good for a quick refresher after this session.
GITQUICK
VIDEO
Computerphile
How Git uses SHA-1 hashes, blobs, trees, and commits internally. Connects directly to the deep-dive.
GIT INTERNALSSHA-1
TOOL
learngitbranching.js.org
Visual, interactive Git sandbox in the browser. Practice commits, branches, and merges with instant visual feedback. Essential.
INTERACTIVEVISUAL
ARTICLE
Chris Beams
The definitive guide to commit message style. The 7 rules every developer should follow.
COMMIT MESSAGESBEST PRACTICE
// LEAVE EXCITED BECAUSE
You have time travel for your code. Every change is recorded permanently. You can undo any mistake, compare any versions, see the exact history of every decision. You will never lose work again.