← back to Designer Wallcoverings

PHASE2-BLOAT-PURGE-PLAN-20260616.md

102 lines

# Phase 2 — Destructive history purge plan (Steve-GATED, DO NOT auto-run)

Repo: `~/Projects/Designer-Wallcoverings`
Starting `.git`: **5.1G**  (blob total in history ~5.34G)
Generated: 2026-06-16, after phase-1 de-index commit `0dca54e`.

Phase 1 (DONE) stopped tracking the offenders + tightened `.gitignore`, but the
blobs still live in history — that's why `.git` is still 5.1G. Phase 2 rewrites
history to physically remove them.

## (a) Remote status — LOW STAKES
**No remote configured** (`git remote -v` is empty). A history rewrite here is
local-only: **no force-push is required and none is possible.** If a GitHub/other
remote is ever added LATER, the first push after this rewrite must be a
`--force-with-lease` and is separately Steve-gated. Local branches present:
`main`, `rotation-prestage` (current), `chore/git-surgery-plan` — filter-repo
rewrites ALL of them.

## Paths targeted (purged from ALL history) and history bytes reclaimed
| path | history bytes |
|------|---------------|
| `vendor-scrapers/china-seas-deheader/cropped/` | 3.9 G |
| `vendor-scrapers/images/` | 545.8 M |
| `DW-Programming/room-setting-app/data/gallery/renders.json` | 76.4 M |
| `DW-Programming/data/color-clean-ledger.jsonl` | 34.8 M |
| `DW-Programming/ImportNewSkufromURL/dwjs-spreadsheet.csv` | 17.1 M |
| `DW-Programming/ImportNewSkufromURL/fmpro-master.csv` | 13.1 M |
| **TOTAL targeted** | **~4.57 G of 5.34 G** |

All six are regenerable staging artifacts / data dumps (china-seas crops are
recreated by `build.py`; the upload was never run). The two CSVs are large
source-data dumps — confirm you don't need their HISTORY (current copies stay on
disk and current-tree tracking was NOT removed for the CSVs in phase 1; only the
4 media/JSON sets were de-indexed). If you want the CSVs out of the *current*
tree too, de-index them first; either way phase 2 strips them from history.

## (d) Expected post-rewrite `.git` size
~0.6–0.8 G (5.34 G blob total − 4.57 G purged ≈ 0.77 G, plus packing slack).
A 5.1G → <1G reduction.

## (b) SAFETY BACKUP — run FIRST, before any rewrite
```sh
# Full cold backup of the repo (working tree + .git) to a timestamped tarball.
cd ~/Projects
tar -czf ~/Designer-Wallcoverings-PREPURGE-$(date +%Y%m%d-%H%M).tar.gz Designer-Wallcoverings
ls -lh ~/Designer-Wallcoverings-PREPURGE-*.tar.gz   # confirm the tarball exists + nonzero
```
(Optional extra: `git bundle create ~/DW-prepurge.bundle --all` for a git-native snapshot.)

## (c) EXACT git-filter-repo command block (git-filter-repo IS installed: /opt/homebrew/bin/git-filter-repo)
filter-repo refuses to run on a repo with uncommitted changes or a non-fresh
clone unless `--force`; the working tree is clean as of phase 1, but it will warn
because this is not a fresh clone. Review, then run:

```sh
cd ~/Projects/Designer-Wallcoverings

# 1. Dry-run analysis first (writes a report, changes nothing):
git filter-repo --analyze
cat .git/filter-repo/analysis/path-all-sizes.txt | head -40   # sanity-check the big paths

# 2. The purge (rewrites ALL refs/branches; --force needed since not a fresh clone):
git filter-repo --force \
  --invert-paths \
  --path 'vendor-scrapers/china-seas-deheader/cropped/' \
  --path 'vendor-scrapers/images/' \
  --path 'DW-Programming/room-setting-app/data/gallery/renders.json' \
  --path 'DW-Programming/data/color-clean-ledger.jsonl' \
  --path 'DW-Programming/ImportNewSkufromURL/dwjs-spreadsheet.csv' \
  --path 'DW-Programming/ImportNewSkufromURL/fmpro-master.csv'
```
Notes:
- `--path` with a trailing `/` matches the whole directory subtree across all history.
- filter-repo treats `--path` as path-PREFIX match by default — exact files match exactly.
- filter-repo auto-removes the `origin` remote; harmless here (no remote anyway).
- The files stay on disk in the working tree (they're gitignored now); only HISTORY is purged.

## (e) Reclaim disk after the rewrite (filter-repo usually does most of this, but force it)
```sh
cd ~/Projects/Designer-Wallcoverings
rm -rf .git/refs/original/                 # drop the backup refs filter-repo leaves
git reflog expire --expire=now --all
git gc --prune=now --aggressive
du -sh .git                                 # expect ~0.6–0.8 G
```

## Post-checks
```sh
git log --oneline | head        # history intact (commit IDs WILL change — that's the rewrite)
git status                       # clean
# spot-confirm a purged path is gone from history:
git rev-list --objects --all | grep -c 'china-seas-deheader/cropped/'   # expect 0
```

## Reminders / gates
- Commit IDs change for every commit (rewrite). Any external reference to old
  hashes (notes, other clones, the `chore/git-surgery-plan` branch) will be stale.
- BFG is NOT installed (filter-repo is preferred and present); no need for BFG.
- If a remote is added afterward, the first push is `--force-with-lease` and is a
  separate Steve-gated action.
- Keep the PREPURGE tarball until you've verified the rewritten repo for a few days.