delorenj

Unfuck My Git State

開発v0.2.1
作者:delorenj更新日 2026-05-11全 3 バージョン · 最新版の公開日 2026-02-06unfuck-my-git-state@clawhub_delorenj/unfuck-my-git-state
Git 補助#Git

AlphaMoatによると、2026-09時点でUnfuck My Git Stateのダウンロード数は3,111、スター数は1で、AIスキル全体5,078件中3,650位、開発では577件中463位です。

インストール数
102
ダウンロード数
3111
スター数
1
総合順位
#3,650
全体の上位 72% · 開発の上位 81%
プラットフォームインストール数ダウンロード数スター数コメント
ClawHub ↗10230831-
SkillHub ↗10131111—

プラットフォームごとに集計方法と集計時点が異なります。

このスキルでできること

最初に状態スナップショットを作成し、症状に応じて手順を選び、非破壊的な方法を優先して各修復後に検証します。.gitメタデータを手動変更する前にはバックアップが必要です。HEAD、参照、worktreeを誤って変更するとリポジトリ状態に影響するため、復旧コマンドを実行する前に症状と対象を特定してください。

資料公開日 2026-10-29

できること

  • Git状態とworktreeの診断情報を収集する。
  • detached HEAD、残存ロック、壊れた参照などの症状に応じた復旧手順を選ぶ。
  • 最小範囲で修正し、その後に検証チェックリストを実行する。

使う場面

  • GitでHEADの不整合、worktreeロック、参照エラーが報告されたとき。
  • リポジトリ状態を診断し、低リスクの復旧計画を立てるとき。
  • .git、ブランチ参照、worktreeを変更する前に、バックアップと対象リポジトリを確認するとき。

プロンプト例

スキルのドキュメントをもとに生成した例であり、実際の実行結果ではありません。

バックアップ対象のメタデータと読み取り専用診断項目を含む状態確認リストを作成してください。修復コマンドは実行しないでください。
このエラーに対する最小限の復旧案を作成し、HEAD、参照、worktreeを変更する手順を示して確認を待ってください。

月次の推移

ダウンロード数3111
2151266731822026-03 · ダウンロード数 22222026-05 · ダウンロード数 25722026-06 · ダウンロード数 26972026-07 · ダウンロード数 29002026-08 · ダウンロード数 29992026-09 · ダウンロード数 311126-0326-09
スター数1
0122026-03 · スター数 12026-05 · スター数 12026-06 · スター数 12026-07 · スター数 12026-08 · スター数 12026-09 · スター数 126-0326-09

2026-09 から集計方法を変更し、同名スキルを作者ごとに分けて集計し、全スキルを対象にしました。破線は変更前の月で、変更後のデータとは直接比較せず、変更をまたぐ増減も計算していません。

月ダウンロード数前月比スター数
2026-093111—1
2026-082999+3.4%1
2026-072900+7.5%1
2026-062697+4.9%1
2026-052572—1
2026-032222—1

SKILL.md 原文

作者が公開した元のファイルをテキストのまま表示しています。AlphaMoat による編集や審査はしていません。リンクはクリックできません。コマンドは内容を確認してから実行してください。取得日 2026-10-23。

4.6 KB・ClawHub v0.2.1
---
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
すべて表示(全 159 行)

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`

開発の人気スキル

データ月:2026-09 · ダウンロード数、スター数、インストール数は公開スキルレジストリ(ClawHub、SkillHub)から月単位で集計しています。詳しくはデータの方法論をご覧ください。