Git from the Terminal

Learn through engaging narratives and interactive challenges

5 lessons available

Lessons

1

The Geometry of Version Control

Git moves your files between four areas: Working Directory (your files on disk), Staging Area (what you've chosen to include in the next commit), Local Repository (your committed history in .git/), and Remote Repository (GitHub). Every Git command is just moving something between these areas. Your desktop GUI hid the Staging Area from you — that's the key piece you were missing.

2

The Nature of Branching

A branch is not a copy of your code. It is a tiny file containing a single 40-character hash pointing to a commit. Creating a branch is instant because Git copies nothing — it just writes a new pointer. HEAD is another pointer that tells Git which branch you're currently on. Merging brings one branch's commits into another — always switch to the target branch first.

3

The Art of Undoing

git log shows your commit history — add --oneline --graph --all for a visual tree of all branches. git diff shows what changed (Working Dir vs Staging, or --staged for Staging vs last commit). Undoing maps to the 4 areas: 'git restore' discards Working Dir changes, 'git restore --staged' unstages, 'git reset' undoes local commits, and 'git revert' safely undoes pushed commits by creating a new undo-commit.

4

Behind the Curtain

The .git folder is Git's entire database. HEAD is a text file pointing to your current branch. Each branch is a file in .git/refs/heads/ containing a 40-character commit hash. The objects/ folder stores every version of every file ever committed. Delete .git and all history vanishes — your files stay but Git is gone. The .gitignore file tells Git which files to never track: build artifacts, IDE configs, secrets, logs.

5

Beyond Your Machine

GitHub is simply a hosted copy of your .git folder with a web interface layered on top. Pull Requests, issues, and code review are GitHub features — the Git underneath is identical to what you do locally. CI/CD (Continuous Integration/Deployment) wires automation to your pushes: push to main, a pipeline runs tests and deploys automatically. Once a pipeline is connected, every 'git push' has real consequences — which is why clean Git habits matter.

Your Progress

0 of 5 lessons completed