dvc gc supports --num with --all-branches
Introduced 2026-03-31 · score 0.95
HOW TO USE IT
When cleaning a shared cache, run `dvc gc` with `--all-branches --num <N>` to keep data referenced by the last N commits from each branch tip. Add `--projects <path>... --force` to preserve the union across the current project and listed projects without a confirmation prompt.
dvc gc --all-branches --num 2 --projects <project-path>... --forceWHY THIS HELPS
When garbage-collecting repositories whose branches share a cache, preserve the last N commits from each branch tip.
REQUIREMENTS AND LIMITATIONS
- Version: 3.67.1
- --all-branches (or -a) (required): Keep cached data referenced in all Git branches, as well as the workspace; with `--num`, select the last N commits from each branch tip.
- --num <num> (or -n <num>) (required): Keep cached data referenced in the last N commits from each selected revision root, as well as the workspace. Can be used with `--all-branches`.
- --projects <paths> (or -p <paths>): Specify one or more project paths whose data should be preserved when projects share a cache or remote; together with `--all-branches --num`, DVC preserves the union across the current and listed projects.
- --force (or -f): Force garbage collection and skip the confirmation prompt.
- Prerequisite: For shared-cache preservation, pass paths for the other DVC projects; ensure their relevant commits and branches have been pulled first.
- The shared-cache union behavior applies when `--projects` repositories share the same cache.
FIRST-PARTY EVIDENCE
- https://github.com/treeverse/dvc/releases/tag/3.67.1
- https://github.com/treeverse/dvc/pull/11013
- https://doc.dvc.org/command-reference/gc
Check the installed version and the source before using it. Entry JSON