Diagnose and recover broken Git state and worktree metadata with a staged, low-risk recovery flow. Use when Git reports detached or contradictory HEAD state, phantom worktree locks, orphaned worktree entries, missing refs, 0000000000000000000000000000000000000000 hashes, or branch operations fail with errors like already checked out, unknown revision, not a valid object name, or cannot lock ref.
数据来源:ClawHub。 在 ClawSkills 查看
选择你使用的 Agent
方法一:命令行安装(推荐)
推荐(无需提前安装 clawhub)
npx clawhub@latest --dir ~/.claude/skills install unfuck-my-git-state或使用 clawhub CLI(需提前安装)
clawhub --dir ~/.claude/skills install unfuck-my-git-state⚠️ 需要 Node.js 18+,没有 Node?请使用下方方法二直接下载 ZIP。 安装 Node.js →
方法二:手动下载安装(无需 Node)
下载 ZIP,解压后将文件夹放到以下路径,重启 Agent 即可:
安装路径
~/.claude/skills/unfuck-my-git-state/💡解压后将文件夹放到上方路径,重启 Agent 即可生效
--- name: unfuck-my-git-state description: Diagnose and recover broken Git state and worktree metadata with a staged, low-risk recovery flow. Use when Git reports detached or contradictory HEAD state, phantom worktree locks, orphaned worktree entries, missing refs, 0000000000000000000000000000000000000000 hashes, or branch operations fail with errors like already checked out, unknown revision, not a valid object name, or cannot lock ref. ---
Recover a repo without making the blast radius worse.
.git/ as production data until backup is taken.git symbolic-ref before manually editing .git/HEAD.bash scripts/snapshot_git_state.sh .
references/symptom-map.md.bash scripts/guided_repair_plan.sh --repo .
references/recovery-checklist.md verification gate.For explicit routing:
bash scripts/guided_repair_plan.sh --list
bash scripts/guided_repair_plan.sh --symptom phantom-branch-lock
Use disposable simulation tests before changing script logic:
bash scripts/regression_harness.sh
Run one scenario:
bash scripts/regression_harness.sh --scenario orphaned-worktree
Symptoms:
git worktree list shows a path that no longer exists.Steps:
git worktree list --porcelain
git worktree prune -v
git worktree list --porcelain
If stale entries remain, back up .git/ and remove the specific stale folder under .git/worktrees/, then rerun prune.
Symptoms:
git branch -d or git branch -D fails with "already used by worktree".git worktree list seems to disagree with branch ownership.Steps:
git worktree list --porcelain
Find the worktree using that branch, switch that worktree to another branch or detach HEAD there, then retry the branch operation in the main repo.
Symptoms:
git status says detached HEAD unexpectedly.git branch --show-current and git symbolic-ref -q HEAD disagree.Steps:
git symbolic-ref -q HEAD || true
git reflog --date=iso -n 20
git switch <known-good-branch>
If branch context is unknown, create a rescue branch from current commit:
git switch -c rescue/$(date +%Y%m%d-%H%M%S)
Then reconnect to the intended branch after investigation.
Symptoms:
unknown revision, not a valid object name, or cannot lock ref.Steps:
git fetch --all --prune
git show-ref --verify refs/remotes/origin/<branch>
git branch -f <branch> origin/<branch>
git switch <branch>
Use reflog to recover local-only commits before forcing branch pointers.
Only after backup of .git/.
Preferred:
git show-ref --verify refs/heads/<branch>
git symbolic-ref HEAD refs/heads/<branch>
Fallback when symbolic-ref cannot be used:
echo "ref: refs/heads/<branch>" > .git/HEAD
Immediately run the verification gate.
Run checks in references/recovery-checklist.md. Minimum bar:
git status exits cleanly with no fatal errors.git symbolic-ref -q HEAD matches intended branch.git worktree list --porcelain has no missing paths and no zero hashes.git fsck --no-reflogs --full has no new critical errors..git:tar -czf git-metadata-backup-$(date +%Y%m%d-%H%M%S).tar.gz .git
When building worktree tooling (iMi, scripts, bots), enforce:
references/symptom-map.mdreferences/recovery-checklist.mdscripts/snapshot_git_state.shscripts/guided_repair_plan.shscripts/regression_harness.sh安装 Unfuck My Git State 后,可以对 AI 说这些话来触发它
Help me get started with Unfuck My Git State
Explains what Unfuck My Git State does, walks through the setup, and runs a quick demo based on your current project
Use Unfuck My Git State to diagnose and recover broken Git state and worktree metadata with a ...
Invokes Unfuck My Git State with the right parameters and returns the result directly in the conversation
What can I do with Unfuck My Git State in my developer & devops workflow?
Lists the top use cases for Unfuck My Git State, with example commands for each scenario
将技能文件夹放到 ~/.claude/skills/unfuck-my-git-state/ 目录(个人级,所有项目可用),或 .claude/skills/unfuck-my-git-state/(项目级)。重启 AI 客户端后,用 /unfuck-my-git-state 主动调用,或让 AI 根据上下文自动发现并使用。
Unfuck My Git State 支持 Claude、Cursor、OpenClaw,可与这些 AI 平台无缝集成,扩展其能力。
Unfuck My Git State 可免费安装使用。请查阅仓库了解许可证信息。
Diagnose and recover broken Git state and worktree metadata with a staged, low-risk recovery flow. Use when Git reports detached or contradictory HEAD state, phantom worktree locks, orphaned worktree entries, missing refs, 0000000000000000000000000000000000000000 hashes, or branch operations fail with errors like already checked out, unknown revision, not a valid object name, or cannot lock ref.
Automate my developer & devops tasks using Unfuck My Git State
Identifies repetitive steps in your workflow and sets up Unfuck My Git State to handle them automatically
Unfuck My Git State 属于「Developer & DevOps」分类,该分类的技能帮助 AI 智能体在此领域执行专业任务。