Git
The commit hygiene, branching strategy, and conflict resolution that keep PRs fast and reviewers happy.
beginner31 labs
By the end you'll be able to
- Write commits a reviewer can actually read
- Resolve merge conflicts without rage-deleting branches
- Recover work after a bad rebase
- Keep a clean PR without forcing-push panic
Labs
- 01StartWhat is version controlBefore any command, build a mental model of version control as a tool that tracks every change, lets teams collaborate, and lets you travel back in time.10 min
- 02StartWhat is a Git repositoryA Git repository is just a folder with a hidden `.git/` directory inside. Once you see what is in there, the magic dissolves.15 min
- 03StartWhat is a commitA commit is a snapshot of your project plus a pointer to the commit before it. See the raw object Git wrote on disk.15 min
- 04StartWhat is a branch and HEADA branch is a movable pointer to a commit. HEAD is a pointer to the branch you are currently on. See both as plain text files on disk.15 min
- 05StartThe three areas, working, staged, committedEvery file in a Git repo lives in one of three areas. Walk a single file through each one and watch `git status` change.20 min
- 06StartConfigure Git identitySet your name and email so Git can stamp every commit you make.15 min
- 07StartInitialize a repoTurn an empty folder into a Git repository with one command and inspect what was created.10 min
- 08StartCheck repo state with git statusRead what Git knows about your working tree in three classic situations.15 min
- 09StartStage changes with git addMove files into the staging area with single-file, bulk, and patch-mode forms of git add.20 min
- 10StartSave snapshots with git commitRecord staged changes into history and read them back with git log.15 min
- 11StartView history with git loggit log walks back through commits. Plain, oneline, and limited views answer different questions.15 min
- 12StartSee what changed with git diffgit diff shows pending changes. Plain, --staged, and commit-range forms cover the everyday questions.20 min
- 13StartInspect a single commit with git showgit show prints one commit's metadata and diff. Pair it with git log to audit a specific change.15 min
- 14StartVisualize history with git log --graphgit log --graph draws an ASCII tree of commits. Combined with --all and --decorate it shows every branch in one view.20 min
- 15StartDiscard working-tree changes with git restoreThrow away unwanted edits in the working tree and unstage files with `git restore`.15 min
- 16StartMove HEAD back with git reset (soft, mixed, hard)Rewind history with `git reset` and feel the difference between `--soft`, `--mixed`, and `--hard`.25 min
- 17StartUndo a public commit safely with git revertUndo a commit on a shared branch by adding a new commit that reverses it, instead of rewriting history.20 min
- 18StartRecover lost commits with git reflogUse `git reflog` to find commits that became unreachable after a hard reset and bring them back.20 min
- 19StartCreate and list branchesA branch is a movable pointer to a commit. `git branch` lists them, `git branch <name>` creates one.15 min
- 20StartMove between branches with git switch`git switch` moves HEAD between branches. `-c` creates and switches in one step. `git checkout` is the legacy verb.15 min
- 21StartDetached HEAD, what it means and how to get outRecognize the detached HEAD state, commit safely while in it, and rescue the work with a new branch.15 min
- 22StartMerge branches (fast-forward and three-way)git merge folds one branch into another. The shape of the merge depends on whether the branches diverged.25 min
- 23StartDelete branches with -d vs -D`git branch -d` refuses to drop unmerged work. `git branch -D` forces the delete and discards the commits.20 min
- 24StartWhat origin meansorigin is just a name. It is an alias for a remote URL or path that git remembers per repo.15 min
- 25StartClone a repo locallygit clone copies a repo into a new folder and wires origin to its source. Practice it against a local bare repo.20 min
- 26Startgit fetch vs git pullfetch downloads without merging. pull is fetch plus merge. Practice both against two clones of the same bare repo.25 min
- 27StartPush commits with git push (-u and --force-with-lease)git push sends local commits to a remote. -u records upstream tracking so later pushes need no arguments. --force-with-lease is the safer alternative to --force.20 min
- 28StartHTTPS vs SSH auth for GitHubGenerate an ed25519 SSH key, inspect a remote URL, and switch a remote from HTTPS to the SSH form.15 min
- 29StartResolve merge conflicts by handWhen two branches change the same line, `git merge` stops with conflict markers. Edit the file, stage it, and commit to finish the merge.25 min
- 30StartAbort a merge and recover the pre-merge stateWalk back a conflicted merge with `git merge --abort` and end up with a clean working tree on the original branch.15 min
- 31StartCapstone, integrate a conflicting branchA realistic team scenario. A feature branch and main both edited the same config line. Merge them and resolve the conflict by hand, keeping the feature's value and main's other change, then commit the merge.22 min