Reclaiming Local Cache Space
As you work with different branches and files, Crab's local cache accumulates objects you may no longer need. Pruning removes cached objects that aren't referenced by any pointer file in your current working tree, freeing disk space without touching the remote store.
How Pruning Works
Prune is purely local and always safe:
- Walks your working tree and collects all content hashes from pointer files.
- Walks the local cache directory (
~/.cache/crab/or$CRAB_CACHE_DIR). - Removes any cached object whose hash isn't in the referenced set.
The remote store always retains the authoritative copy. Pruned objects can be re-fetched anytime with crab hydrate.
Usage
Preview what would be removed
crab prune --dry-runprune (dry run): would remove 15 objects (234567890 bytes)Run the prune
crab pruneprune complete: removed 15 objects (234567890 bytes freed)Verbose output (see each object)
crab prune --verboseExtra safety: verify remote before deleting
crab prune --verify-remoteWith --verify-remote, Crab confirms each object exists on the remote before deleting it locally. This prevents pruning objects that haven't been pushed yet.
When to Prune
| Scenario | Why it helps |
|---|---|
| After switching branches | Cleans up objects from the previous branch |
After crab dehydrate | Removes cached chunks for dehydrated files |
| Disk space is low | Reclaims cache space without affecting the remote |
| Periodic maintenance | Keeps the cache lean over time |
Prune vs. GC
These are different operations at different scopes:
crab prune | crab gc | |
|---|---|---|
| Scope | Local cache only | Remote store |
| Safety | Always safe — remote is untouched | Requires careful reference checking |
| Reversibility | Objects re-fetched on next hydrate | Deleted objects are gone permanently |
| When to use | Free local disk space | Remove unreachable remote objects |
Cache Location
The local cache defaults to ~/.cache/crab/. Override with:
export CRAB_CACHE_DIR=/path/to/cacheCLI Reference
For complete command syntax and all available flags, see the crab prune reference.