据 AlphaMoat 统计,截至 2026-09,Unfuck My Git State 累计下载 3,111 次、获 1 个星标,在全部 5,078 个 AI 技能中排名第 3,650 位,在「开发编程」分类(577 个)中排名第 463 位。
| 平台 | 累计安装 | 累计下载 | 星标 | 评论 |
|---|---|---|---|---|
| ClawHub ↗ | 102 | 3,083 | 1 | - |
| SkillHub ↗ | 101 | 3,111 | 1 | — |
各平台的计数口径不同,统计时间不一致。
流程要求先创建状态快照、根据症状选择修复方案,优先采用非破坏性步骤,并在每次修复后验证;手动修改 .git 元数据前应先备份。错误地调整 HEAD、引用或 worktree 可能影响仓库状态,因此应先明确症状和目标,避免直接执行不匹配的恢复命令。
资料发布于 2026-10-29
.git、分支引用或 worktree 的操作前,需要先备份并核实目标仓库时。以下是根据技能文档生成的示例,不代表实际运行结果。
2026-09 起统计方法调整:同名技能按作者分别统计,并覆盖全部技能。图中虚线为调整前的月份,与之后的数据不直接比较,也不计算跨越调整的增长。
| 月份 | 累计下载 | 环比 | 星标 |
|---|---|---|---|
| 2026-09 | 3,111 | — | 1 |
| 2026-08 | 2,999 | +3.4% | 1 |
| 2026-07 | 2,900 | +7.5% | 1 |
| 2026-06 | 2,697 | +4.9% | 1 |
| 2026-05 | 2,572 | — | 1 |
| 2026-03 | 2,222 | — | 1 |
以下是作者发布的原始文件,按纯文本显示,本站未做修改或审核;其中的链接不可点击,命令请核实后再运行。抓取于 2026-10-23。
--- 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. --- # unfuck-my-git-state Recover a repo without making the blast radius worse. ## Core Rules
1. Snapshot first. Do not "just try stuff." 2. Prefer non-destructive fixes before force operations. 3. Treat `.git/` as production data until backup is taken. 4. Use `git symbolic-ref` before manually editing `.git/HEAD`. 5. After each fix, run verification before proceeding. ## Fast Workflow 1. Capture diagnostics: ```bash bash scripts/snapshot_git_state.sh . ``` 2. Route by symptom using `references/symptom-map.md`. 3. Generate non-destructive command plan: ```bash bash scripts/guided_repair_plan.sh --repo . ``` 4. Apply the smallest matching playbook. 5. Run `references/recovery-checklist.md` verification gate. 6. Escalate only if the gate fails. For explicit routing: ```bash bash scripts/guided_repair_plan.sh --list bash scripts/guided_repair_plan.sh --symptom phantom-branch-lock ``` ## Regression Harness Use disposable simulation tests before changing script logic: ```bash bash scripts/regression_harness.sh ``` Run one scenario: ```bash bash scripts/regression_harness.sh --scenario orphaned-worktree ``` ## Playbook A: Orphaned Worktree Metadata Symptoms: - `git worktree list` shows a path that no longer exists. - Worktree entries include invalid or zero hashes. Steps: ```bash 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/<name>`, then rerun prune. ## Playbook B: Phantom Branch Lock Symptoms: - `git branch -d` or `git branch -D` fails with "already used by worktree". - `git worktree list` seems to disagree with branch ownership. Steps: ```bash 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. ## Playbook C: Detached or Contradictory HEAD Symptoms: - `git status` says detached HEAD unexpectedly. - `git branch --show-current` and `git symbolic-ref -q HEAD` disagree. Steps: ```bash 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: ```bash git switch -c rescue/$(date +%Y%m%d-%H%M%S) ``` Then reconnect to the intended branch after investigation. ## Playbook D: Missing or Broken Refs Symptoms: - `unknown revision`, `not a valid object name`, or `cannot lock ref`. Steps: ```bash 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. ## Last Resort: Manual HEAD Repair Only after backup of `.git/`. Preferred: ```bash git show-ref --verify refs/heads/<branch> git symbolic-ref HEAD refs/heads/<branch> ``` Fallback when `symbolic-ref` cannot be used: ```bash echo "ref: refs/heads/<branch>" > .git/HEAD ``` Immediately run the verification gate. ## Verification Gate (Must Pass) 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. ## Escalation Path 1. Archive `.git`: ```bash tar -czf git-metadata-backup-$(date +%Y%m%d-%H%M%S).tar.gz .git ``` 2. Clone fresh from remote. 3. Recover unpushed work with reflog and cherry-pick from old clone. 4. Document failure mode and add guardrails to automation. ## Automation Hooks When building worktree tooling (iMi, scripts, bots), enforce: - preflight snapshot and state validation - post-operation verification gate - hard stop on HEAD/ref inconsistency - explicit user confirmation before destructive commands ## Resources - Symptom router: `references/symptom-map.md` - Verification checklist: `references/recovery-checklist.md` - Diagnostic snapshot script: `scripts/snapshot_git_state.sh` - Guided plan generator: `scripts/guided_repair_plan.sh` - Disposable regression harness: `scripts/regression_harness.sh`
用 gh 命令行工具查看 GitHub 上的 PR 检查、工作流运行与 API 查询的技能。
聚合 16 个搜索引擎、无需 API Key 的检索技能。
用命令行直接列出、配置、授权并调用 MCP 服务与工具。
根据文字描述生成 Mermaid 图表代码。
用受管 OAuth 访问 YouTube Data API,检索视频并管理频道内容。
通过受管的 OAuth 连接访问 GitHub REST API。
覆盖规划、实现、验证与测试的编码工作流技能。
整理 Docker 常用命令与容器工作流的技能。
数据月份:2026-09 · 下载/星标/安装数聚合自公开技能注册库(ClawHub、SkillHub),按月更新。口径说明见数据方法。