{
  "id": "git/am-failed-patch",
  "signature": "error: patch failed: file.txt:1\nerror: file.txt: patch does not apply",
  "signature_zh": "错误：补丁失败：file.txt:1\n错误：file.txt: 补丁无法应用",
  "regex": "error:\\s+patch\\s+failed:\\s+[^:]+:\\d+\\n.*patch\\s+does\\s+not\\s+apply",
  "domain": "git",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A patch file (from git format-patch or email) cannot be applied because the target file has diverged from the patch's base.",
  "root_cause_type": "generic",
  "root_cause_zh": "补丁文件（来自git format-patch或邮件）无法应用，因为目标文件与补丁的基础版本存在差异",
  "versions": [
    {
      "version": "git 2.41.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "git 2.42.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "git 2.43.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Using 'git am --3way' without checking for conflicts first",
      "why_fails": "3-way merge may still fail if the patch context is too old",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Manually editing the patch file to change line numbers",
      "why_fails": "Patch context (surrounding lines) must match exactly; changing line numbers alone doesn't fix context mismatches",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Apply the patch with 'git apply --reject' to see which hunks fail, then manually fix: git apply --reject patch.diff && vim file.txt",
      "success_rate": 0.85,
      "how": "Apply the patch with 'git apply --reject' to see which hunks fail, then manually fix: git apply --reject patch.diff && vim file.txt",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use 'git am --3way --ignore-whitespace' to apply with more tolerance: git am --3way --ignore-whitespace patch.mbox",
      "success_rate": 0.75,
      "how": "Use 'git am --3way --ignore-whitespace' to apply with more tolerance: git am --3way --ignore-whitespace patch.mbox",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Apply the patch with 'git apply --reject' to see which hunks fail, then manually fix: git apply --reject patch.diff && vim file.txt",
    "Use 'git am --3way --ignore-whitespace' to apply with more tolerance: git am --3way --ignore-whitespace patch.mbox"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://git-scm.com/docs/git-am",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.82,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2023-09-05",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}