Skip to content
academia.sh

Course Advanced

Advanced Git

By the end of this course

Start course

01

Rewriting History

Squashing, editing, and reordering commits; the cost of changing the past repository-wide; force push discipline on shared branches; and recovering lost commits with the reflog.

  1. 01 Interactive Rebase Changing a commit changes the identity of every commit after it; rewriting from the middle touches 252, 362, 3002, and 11322 objects in 50-, 200-, 1000-, and 4000-commit histories respectively, and the ratio stays at roughly half at every scale.
  2. 02 Bulk History Transformation A repository-wide transformation starts from the first commit: in a thousand-commit history, 1000 identities change, 5640 objects are touched, and the new history does not share a single commit with the old one — so every copy has to be re-cloned and the operation cannot be undone.
  3. 03 Force Push Discipline In a thousand-commit history, changing the last commit changes 1 identity, changing the first changes 1000; but in both cases all seven of seven copies have to resync, and the stranded local work stays the same — the cost scales with the number of copies, not the size of the change.
  4. 04 Reflog Rewriting does not shorten history, it doubles it: in a thousand-commit repository, a transformation from the first commit leaves 1000 commits reachable and 1000 unreachable; in a six-entry log, when the retention horizon is 7, 30, 60, and 90 days, the recoverable commits are 3, 50, 500, and 1000.

02

Diagnostic Tools

Finding the commit a regression was introduced in with binary search, tracing a line's history, and when client-side and server-side hooks fire.

  1. 01 Bug Hunting with Bisect The cost of asking history a question is measured in steps: to find the same bug, linear search spends 37, 150, 750, and 3000 steps while binary search finishes in 6, 7, 9, and 11, and the grouping that cheapens the search coarsens the resolution of the answer.
  2. 02 Blame and Line History The cost of blame is the number of commits that touch a file, and in the same history it climbs to 8, 36, 209, and 787 steps; next to binary search's 11 steps this is a second growth form, and however long the scan runs, the answer stays bounded by the file's line count.
  3. 03 Hooks A hook is an event point, and the moment the block is set determines the cost: a change stopped before commit touches zero objects, before push ten commits and 140 objects, six hundred commits after acceptance 601 commits, 3522 objects, and all seven of the seven copies.

03

Large Repositories

Embedding dependent repositories and pinning versions, the weight binary assets bring to history, working in parallel on the same repository, line-ending and merge-driver settings, and the scale trade-off between a monorepo and a polyrepo.

  1. 01 Submodules A submodule writes an identity to the main repository, not a history: three submodules bind one commit to four separate histories, 76 objects written by 38 commits bring in 378 submodule commits, and a recursive clone climbs from 920 objects to 4540.
  2. 02 Large File Storage What weighs down history is not commit count but object type: fewer than a tenth of a thousand commits — 91 binary commits — produce 0.6777 of the total objects; the clone is 5640 objects and drops to 1818 without binaries.
  3. 03 Multiple Working Trees An extra working tree shares the object store and copies 0 objects: in a thousand-commit history, the clone scheme writes 22560 objects for four branches while the tree scheme stays at 5640; 11466 of the 16920 gained objects are binary.
  4. 04 Repository Attributes The attributes file determines which operation behaves how on which file: an unconfigured thousand-commit history writes 5888 objects, line endings produce 162 unnecessary objects, and 43 of fifty merges conflict in the generated file, adding 86 more objects.
  5. 05 Monorepo and Polyrepo The same work under two schemes: total objects are 22600 in both, but the cost per repository is 22600 versus 5650, bisect is 11 versus 36 steps, and of four cross-component questions the monorepo answers 4 while the polyrepo answers 1.

Start typing to search.

↑↓ Esc navigate · open · close