Git & GitHub, made simple.

All chapters

Read top to bottom, or jump straight to your error.

Basics

Install Git and learn the daily save cycle.

Branching & History

Work on ideas in parallel and read the project’s past.

GitHub & Collaboration

Put your code online and work with other people.

Fix-it / Rescue

Something looks wrong? Find your exact error and fix it — both ways.

16Discard & Unstage Changes

The gentlest undos: throw away edits with restore, pull a file back out of staging with restore --staged, and clear untracked leftovers with clean's dry run.

17Undo Commits (amend, reset, revert)

Fix the last commit with --amend, un-commit with reset (soft/mixed/hard decoded), and safely reverse an already-pushed commit with revert.

18Committed on the Wrong Branch

Committed on main by mistake? Move the commit to a new or existing branch with branch, cherry-pick and reset — the commit itself is never lost.

19Detached HEAD, Explained

Why Git says "You are in detached HEAD state", what HEAD actually is, and the two ways out — switch back to main, or keep your commits on a new branch.

20Recover Lost Work (reflog)

Work vanished after a reset --hard or a deleted branch? Read Git's private diary with git reflog, find the lost commit's hash, and bring it back.

21Push Rejected & Diverged Branches

Decode "! [rejected] (fetch first)" and "your branches have diverged": pull then push, the Sync Changes button, pull --rebase, and why --force is a trap.

22Fix GitHub Login Errors

Cure "password authentication was removed" and "Authentication failed": sign in with gh auth login, flush stale saved tokens, and fix wrong-account 403s.

23File Too Large to Push

Fix GitHub's GH001 100 MB error: untrack the file with rm --cached and amend, stop committing node_modules, and when Git LFS is actually worth it.

24CRLF vs LF on Windows

Why Git warns "LF will be replaced by CRLF", why it's harmless, the core.autocrlf one-time fix, VS Code's status-bar switch, and .gitattributes for teams.

25Rename master to main

Four commands to rename your default branch: git branch -m, push -u, switch GitHub's default in Settings, and make every new repo start on main.

Reference

The one-page lookup.

New to the command line? Don’t worry — you can do almost everything from VS Code’s Source Control panel, and every step below shows you exactly where to click.