Study notes · 10% of the exam

Bisect, Worktrees, Submodules, LFS and Hooks

Advanced Git is about tools for finding regressions, juggling several checkouts, composing repositories, handling large files, automating with hooks and plumbing, and knowing which of these are local conveniences versus enforceable controls.

Key points

  1. 1

    git bisect binary-searches history; bisect run uses exit codes: 0 good, 125 skip, 1–127 bad, ≥128 aborts.

  2. 2

    Worktrees share objects and refs but each has its own HEAD, index and files; a branch can be checked out in only one worktree.

  3. 3

    Submodules are gitlinks (mode 160000) pinning a commit; clone with --recurse-submodules or run git submodule update --init --recursive.

  4. 4

    Git LFS stores ~130-byte pointers in history; without LFS installed (or lfs: true in CI) you get the pointer text instead of the file.

  5. 5

    Hooks are never cloned; share them via core.hooksPath or a hook manager, and enforce policy server-side or in CI because --no-verify skips client hooks.

  6. 6

    Scripts should use plumbing and porcelain modes: status --porcelain, rev-parse --verify --quiet, for-each-ref, and exit codes like diff --quiet.

  7. 7

    For huge repos: partial clone (--filter=blob:none), cone-mode sparse checkout, and git maintenance keep things fast without losing history.

Common traps

  • Setting core.hooksPath makes Git ignore everything still in .git/hooks/.

  • Commits made inside a submodule on a detached HEAD become unreachable after the next submodule update.

  • git lfs track doesn't shrink existing history; only git lfs migrate import (a history rewrite) does.

Test yourself on Bisect, Worktrees, Submodules, LFS and Hooks

Ten questions, with the answer and explanation after each one.