Skip to main content
Generated from bd help --doc compact. Squash Dolt commits older than N days into a single commit. Recent commits (within the retention window) are preserved via cherry-pick. This reduces Dolt storage overhead from auto-commit history while keeping recent change tracking intact. For semantic issue compaction (summarizing closed issues), use ‘bd admin compact’. For full history squash, use ‘bd flatten’. How it works:
  1. Identifies commits older than —days threshold
  2. Creates a squashed base commit from all old history
  3. Cherry-picks recent commits on top
  4. Swaps main branch to the compacted version
  5. Prunes remote-tracking refs (they would keep the old history alive; the next push or fetch re-creates them at the new tip)
  6. Runs a full Dolt GC (all storage generations) to reclaim the old history
Compact refuses, and changes nothing, when commit dates are out of history order across the cutoff: a recent commit that comes at or before an old commit in history is already part of the squashed base, and replaying it again could change data. The error names both commits; —force does not override it, and —dry-run reports the refusal. Before swapping main, compact also checks that the replayed history holds the same committed data main held when compact read its history, and aborts without resetting main if it does not. A write that reaches main while compact runs is kept, not counted as a difference: uncommitted changes stay pending, and a commit that lands meanwhile is kept in one follow-up commit. The GC pass is a full collection: Dolt storage is generational, and a default GC never revisits data an earlier GC moved to the old generation. On any store that has been GC’d before (bd gc, or a previous flatten or compact), only a full collection reclaims the squashed history. A full GC can take minutes on multi-gigabyte stores. Examples: bd compact —dry-run # Preview: show commit breakdown bd compact —force # Squash commits older than 30 days bd compact —days 7 —force # Keep only last 7 days of history bd compact —days 90 —force # Conservative: squash 90+ day old commits
Flags: