Glossary#
| Term | Plain meaning | Chapter |
|---|---|---|
| version control / Git | tracking every version of files / the dominant tool | 1 |
| distributed | every clone has the full history | 1 |
| GitHub / GitLab | hosting + collaboration services for Git | 1 |
repository / .git | a tracked project / where Git keeps its history | 2 |
| working directory | the files you see and edit | 2 |
| staging area / index | the changes that will go into the next commit | 2 |
| commit | a saved snapshot with message, author, time, parent | 2, 3 |
| untracked | a file Git isn't tracking yet | 2 |
| hash / SHA-1 | content fingerprint / the 40-hex-character hash Git uses | 3 |
| blob / tree / commit object | file contents / directory listing / snapshot record | 3 |
| parent | the previous commit a commit points to | 3 |
| branch | a movable pointer to a commit | 4 |
| HEAD / detached HEAD | "you are here" / pointing at a commit, not a branch | 4 |
| merge / fast-forward / three-way merge | combine branches / just move the pointer / combine via merge base | 5 |
| merge base / merge commit | last shared commit / a commit with two parents | 5 |
| merge conflict / conflict markers | same lines changed differently / <<<<<<< ======= >>>>>>> | 5 |
| rebase / interactive rebase / squash | replay commits elsewhere / edit a series of commits / combine commits | 6 |
| remote / origin | another copy of the repo / its default name | 7 |
| clone / fetch / pull / push | copy / download / download + integrate / upload | 7 |
remote-tracking branch (origin/main) | your record of the remote's branch | 7 |
force push / --force-with-lease | overwrite remote history / only if nobody else pushed | 7 |
| pull request / code review | proposed merge with discussion / teammates checking it | 8 |
| branch protection | rules forcing changes through reviewed PRs | 8 |
| trunk-based / GitFlow / feature flag | short branches to main / long-lived develop+release / runtime on/off switch | 8 |
| restore / amend / reset / revert | discard edits / redo last commit / move branch back / add an undoing commit | 9 |
| stash | park uncommitted changes | 9 |
| reflog | log of every place HEAD has been | 9 |
.gitignore / Git LFS | files never to track / storage for big files | 10 |
| secret scanning | tools that catch keys before/after commit | 10 |
| diff / blame / cherry-pick / tag | compare / who changed each line / copy one commit / name a release | 11 |
| bisect | binary search through history for the breaking commit | 11 |
Cheat Sheet#
Daily
git status · git add -p · git commit -m "Imperative summary" · git log --oneline --graph
git switch main && git pull --rebase · git switch -c feature/x · git push -u origin feature/xCombine
git merge other conflicts → edit, remove markers → git add → git commit (git merge --abort)
git rebase main own unshared commits only (git rebase --abort)Undo — choose by situation
uncommitted edits git restore file (lost forever)
unstage git restore --staged file
last commit, not pushed git commit --amend
local commits git reset --soft|--mixed|--hard HEAD~N
pushed commit git revert <hash> ← the safe one for shared branches
switch tasks git stash / git stash pop
"I lost it" git reflog → git reset --hard <hash>Never
commit .env / keys / node_modules / venv rebase or reset shared commits git push --force to main
leaked secret → ROTATE FIRST, then purge historyInvestigate
git diff --staged · git show <hash> · git blame file · git log -p file
git bisect start / bad / good <tag> / ... / reset (git bisect run ./test.sh)Try This Yourself#
Recreate the conflict. In
~/git-practice, follow Chapters 2, 4 and 5 exactly: commitquiz.py, branch tobonus, change the return line differently on each branch, merge, resolve, and check yourgit log --oneline --graph --allmatches the one in Chapter 5 (your hashes will differ — why? Hint: Ch 3 — your name, email and time are part of the commit).Break it and recover. Run
git reset --hard HEAD~2. Checkgit log— commits gone. Now usegit reflogto find them and restore the branch. Then trygit reverton one commit and look at the new commit it creates withgit show.Bisect for real. Write a loop that makes 20 commits, each appending a number to
nums.txt, and on commit 13 also create a filebug.txt. Then bisect with the test "isbug.txtmissing?" —git bisect run sh -c '[ ! -f bug.txt ]'— and confirm Git names commit 13.