Theory

Updated

October 30, 2026

Theory: The Index is a Filter; LFS is a Pointer

Git will store any blob you add. Ignore rules and attributes are policy on what enters the index and how it is treated. LFS replaces a large blob with a tiny pointer blob and puts the real bytes elsewhere.

Invariants

  1. .gitignore applies to untracked files. A tracked file stays tracked until git rm --cached.
  2. Precedence: command-line exclude → .git/info/exclude → .gitignore in-tree → global excludes file.
  3. gitattributes attach behavior to paths: text vs binary, eol, diff, merge, filter (clean/smudge).
  4. Git LFS stores a pointer file (text, few hundred bytes) in Git, and the payload in an LFS object store the forge must provide.
  git add huge.bin     without LFS     blob of huge.bin in .git/objects
  git add huge.bin     with LFS        blob of pointer  version https://git-lfs...
                                       payload ──► LFS store (not in packfiles)

Why Git is a bad backup of videos

Every clone downloads every version of every blob (unless partial clone / LFS / sparse). A 200 MB binary edited ten times is ~2 GB of packfile. LFS and “do not commit build output” are the same theory: Git’s object store is for source, not for arbitrary bytes.

What can break

  • Ignoring .env after it was committed (must rm --cached).
  • CRLF filters on a Linux-only repo.
  • Pushing LFS pointers to a forge with no LFS storage; clones get pointers, not files.

How to read this chapter

Patterns, attributes, archive, LFS, then a lab. Platform chapters later must store LFS if you use it.