Repository Size Cleanup

Current state

Local inspection on 2026-04-04 found:

  • .git size: about 1.4G
  • packed objects: about 1.35 GiB
  • loose objects: 0
  • garbage objects: 0

This means the size is in committed history, not in disposable local Git metadata.

Largest historical contributors found so far:

  • results/: about 635 MiB
  • .Rlib/: about 444 MiB
  • .cache/: about 279 MiB
  • assets/: about 183 MiB
  • code_review/: about 125 MiB

Largest file classes found so far:

  • .rds: about 1.0 GiB
  • .pdf: about 184 MiB
  • .a: about 131 MiB
  • .so: about 118 MiB

The main current tracking gap is code_review/benchmarks/**/cache/, which is still versioned in HEAD.

Goal

Reduce future repository growth immediately, then decide separately whether to rewrite history to shrink existing clones.

Phase 1: Stop future growth

This phase is low risk and should be merged first.

Ignore rules

The repository should ignore:

  • /.Rlib/
  • /.cache/
  • /results/
  • /code_review/benchmarks/**/cache/
  • /assets/books/

/.Rlib/, /.cache/, and /results/ were already ignored before this note. The new additions are:

  • /code_review/benchmarks/**/cache/
  • /assets/books/

Remove cached benchmark artifacts from Git index

This removes tracked cache files from HEAD without deleting the local copies:

git rm -r --cached code_review/benchmarks/parity_blm/cache
git rm -r --cached code_review/benchmarks/parity_hierarchical/cache
git commit -m "chore: stop tracking benchmark caches"

Current tracked files that should be removed from the index:

code_review/benchmarks/parity_blm/cache/main/dsambayes/1.2.0/models/bayes_lm_updater_revised.rds
code_review/benchmarks/parity_blm/cache/refactor/dsambayes/1.2.0/models/bayes_lm_updater_revised_0d26146603.rds
code_review/benchmarks/parity_hierarchical/cache/main/dsambayes/1.2.0/models/hierarchical_1.rds
code_review/benchmarks/parity_hierarchical/cache/main/dsambayes/1.2.0/models/hierarchical_1.stan
code_review/benchmarks/parity_hierarchical/cache/refactor/dsambayes/1.2.0/models/hierarchical_1_centered_offset.stan
code_review/benchmarks/parity_hierarchical/cache/refactor/dsambayes/1.2.0/models/hierarchical_1_centered_offset_665e33077c.rds

Validation after Phase 1

Run:

git status --short
git check-ignore -v --no-index code_review/benchmarks/parity_blm/cache/main/dsambayes/1.2.0/models/example.rds
git check-ignore -v --no-index assets/books/example.pdf

Expected result:

  • benchmark cache files are ignored
  • local cache files remain on disk
  • repository history size does not materially shrink yet

Phase 2: Shrink existing history

This phase is disruptive and should only happen after coordination with every collaborator and any CI jobs or deployment hooks that clone this repository.

Safety rules

  • Freeze merges to main during the rewrite window.
  • Ask every collaborator to stop pushing until the rewrite is complete.
  • Create a backup mirror before modifying history.
  • Use a temporary clone or mirror for the rewrite, not an active working copy.

Suggested backup

cd ..
git clone --mirror DSAMbayes-Charles-Dev DSAMbayes-Charles-Dev.git-backup

Suggested rewrite target set

Remove historical content for paths that are local caches or generated outputs:

  • /.Rlib/**
  • /.cache/**
  • /results/**
  • /code_review/benchmarks/**/cache/**
  • /assets/books/**

Suggested workflow with git filter-repo

Use a fresh mirror clone:

cd ..
git clone --mirror <remote-url> DSAMbayes-Charles-Dev.git-rewrite
cd DSAMbayes-Charles-Dev.git-rewrite
git filter-repo \
  --path-glob '.Rlib/**' \
  --path-glob '.cache/**' \
  --path-glob 'results/**' \
  --path-glob 'code_review/benchmarks/**/cache/**' \
  --path-glob 'assets/books/**' \
  --invert-paths
git reflog expire --expire=now --all
git gc --prune=now --aggressive

Then verify size:

git count-objects -vH
du -sh .

Publish rewritten history

Only after verification:

git push --force --mirror

If branch protections block force-pushes, temporarily adjust them before the rewrite window and restore them immediately after.

Collaborator recovery after rewrite

Every collaborator should re-clone. If someone must salvage local work, they should:

git fetch origin
git switch main
git reset --hard origin/main

Re-cloning is still safer than trying to reuse an old clone after a large rewrite.

Phase 3: Optional future hardening

If large binary artifacts must remain versioned in future, move them to Git LFS. Do not use Git LFS for ephemeral caches, run outputs, or package libraries that should stay untracked.

  1. Merge the .gitignore change.
  2. Remove tracked benchmark cache files from the index with git rm --cached.
  3. Confirm CI and docs are unaffected.
  4. Decide whether the current 1.4G .git size justifies a history rewrite.
  5. If yes, schedule a short maintenance window and perform the rewrite from a mirror clone.