{
  "id": "git/fatal-override-branch-restriction",
  "signature": "fatal: cannot update ref 'refs/heads/main': trying to write non-commit object to branch 'main'",
  "signature_zh": "致命错误：无法更新引用 'refs/heads/main'：试图将非提交对象写入分支 'main'",
  "regex": "fatal: cannot update ref 'refs/heads/[^']+': trying to write non-commit object to branch '[^']+'",
  "domain": "git",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A commit or update operation is attempting to write a non-commit object (like a tree or blob) directly to a branch reference, which violates Git's object model.",
  "root_cause_type": "generic",
  "root_cause_zh": "提交或更新操作试图将非提交对象（如树或 blob）直接写入分支引用，违反了 Git 的对象模型。",
  "versions": [
    {
      "version": "git 2.35.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "git 2.40.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "git 2.44.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Running git fsck and then git gc without understanding the corruption source can remove necessary objects and worsen the repository state.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Using git update-ref -d to delete the branch reference entirely loses all commits on that branch, which is irreversible unless you have a backup.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "git reflog --all | grep <commit-hash>  # Find the correct commit object, then use git branch -f main <correct-commit> to reset the branch to a valid commit",
      "success_rate": 0.75,
      "how": "git reflog --all | grep <commit-hash>  # Find the correct commit object, then use git branch -f main <correct-commit> to reset the branch to a valid commit",
      "condition": "",
      "sources": []
    },
    {
      "action": "git update-ref -m 'reset to valid commit' refs/heads/main <valid-commit-hash>  # Directly update the ref to a known good commit from reflog or backup",
      "success_rate": 0.8,
      "how": "git update-ref -m 'reset to valid commit' refs/heads/main <valid-commit-hash>  # Directly update the ref to a known good commit from reflog or backup",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "git reflog --all | grep <commit-hash>  # Find the correct commit object, then use git branch -f main <correct-commit> to reset the branch to a valid commit",
    "git update-ref -m 'reset to valid commit' refs/heads/main <valid-commit-hash>  # Directly update the ref to a known good commit from reflog or backup"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://git-scm.com/docs/git-update-ref",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.8,
  "resolvable": "partial",
  "first_seen": "2024-01-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}