From 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 HEAD, phantom worktree locks, orphaned entries, missing refs, or branch operations fail.
How this skill is triggered — by the user, by Claude, or both
Slash command
/unfuck-my-git-state:unfuck-my-git-stateThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Recover a repo without making the blast radius worse.
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.Symptoms: git worktree list shows a path that no longer exists; invalid or zero hashes.
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.
Symptoms: git branch -d fails with "already used by worktree".
git worktree list --porcelain
Find the worktree using that branch, switch that worktree to another branch or detach HEAD there, then retry.
Symptoms: git status says detached HEAD unexpectedly.
git symbolic-ref -q HEAD || true
git reflog --date=iso -n 20
git switch <known-good-branch>
# or create rescue branch:
git switch -c rescue/$(date +%Y%m%d-%H%M%S)
Symptoms: unknown revision, not a valid object name, cannot lock ref.
git fetch --all --prune
git show-ref --verify refs/remotes/origin/<branch>
git branch -f <branch> origin/<branch>
git switch <branch>
Only after backup of .git/.
git show-ref --verify refs/heads/<branch>
git symbolic-ref HEAD refs/heads/<branch>
# fallback:
echo "ref: refs/heads/<branch>" > .git/HEAD
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.tar -czf git-metadata-backup-$(date +%Y%m%d-%H%M%S).tar.gz .git
# Clone fresh from remote, recover with reflog + cherry-pick
npx claudepluginhub billyfranklim1/claude-skills --plugin unfuck-my-git-stateCovers advanced git workflows: worktrees for parallel branches, bisect for bug hunting, interactive rebase for history editing, hooks for automation, and recovery techniques for lost commits.