Git's repack --drop-filtered reclaims the disk a partial clone quietly took back
Описание и применение
Команда git repack --drop-filtered удаляет промисорные объекты из частичных клониров, экономя место на диске и предотвращая лишние сетевые запросы, но требует, чтобы ни один из отфильтрованных объектов не был в индексе.
Задача
Partial clones with --filter=blob:limit keep promisor objects that grow the .git directory and are not cleaned up by normal housekeeping, causing disk bloat and costly refetches.
Результат
git repack --drop-filtered efficiently removes promisor objects from partial clones, reclaiming disk space and preventing unnecessary network fetches, but it aborts if any filtered blob is referenced by the current index.
Рабочий процесс
- Clone repo with --filter=blob:limit=1m
- Perform history traversal (e.g., detached checkouts)
- Run git repack -a -d --filter=blob:limit=1m --drop-filtered
- Verify .git size and asset integrity
- Optionally switch back to main to refetch needed assets
Доказательства
git repack --drop-filtered was merged on 25 August 2026. It is not in 2.55.0 — I checked the tag — and it is on course for 2.56
120 blobs gone in 36 milliseconds. The documentation says it rebuilds the promisor pack without those objects and then deletes the now-redundant old packs
fatal: cannot drop 'assets/asset1.bin' (6ee0d39165f32c48d1236fb18eb1b2dd5c94f712): it is referenced by the current index
- Дата записи: 2026-09-15T11:30:55.109Z