{
  "slug": "dvc-gc-supports-num-with-all-branches-18f1d97354fc",
  "title": "dvc gc supports --num with --all-branches",
  "tools": [
    "dvc"
  ],
  "tags": [
    "agent"
  ],
  "introduced_at": "2026-03-31T05:06:44.000Z",
  "announced_at": "2026-03-31T05:06:44.000Z",
  "effective_at": null,
  "date_basis": "source-publication",
  "status": "unknown",
  "how": {
    "incantation": "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.",
    "examples": [
      "dvc gc --all-branches --num 2 --projects <project-path>... --force"
    ],
    "gotchas": [
      "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."
    ]
  },
  "why_it_matters": "When garbage-collecting repositories whose branches share a cache, preserve the last N commits from each branch tip.",
  "sources": [
    "https://github.com/treeverse/dvc/releases/tag/3.67.1",
    "https://github.com/treeverse/dvc/pull/11013",
    "https://doc.dvc.org/command-reference/gc"
  ],
  "rank": 0.95032,
  "judge": {
    "publish": true,
    "judge_model": "codex-cli/gpt-6-luna+typesafe/jev-1.13.0",
    "prompt_version": "extract-v7+enrich-v2+judge-v2x3+jev-publish-v1"
  },
  "review_state": "approved",
  "provenance": {
    "run_id": "wave2b-20261017",
    "verdict_id": "wave2b-20261017:wave2b-20261017-72a7f5028b2d4a8c-0:gate",
    "evidence_hash": "678cf344917ad3bf13cb38716304109efcd5b34b65064b180fe4b537652a49e7"
  },
  "review": {
    "draft_hash": "4a5edff9908fe89dcd0f15eea958215cad1279651f70ca09e02adef805afa8d8",
    "reviewer": "publication-gate",
    "reviewed_at": "2026-10-07T00:00:00.000Z",
    "decision": "wave2b-20261017:gate",
    "reason": "3 of 3 judge runs approved with p_yes >= 0.9 (mean 0.95 >= 0.9; 2 needed) and Jev gave 0.71 (>= 0.6 needed)."
  }
}
