/git-workflow:git-deadlock-plumbing-recoveryfrom git-workflow
Diagnose and recover git operations that HANG / DEADLOCK at ~0% CPU on macOS (APFS) — git commit, git reset, git gc/repack, git push, and even git status never returning. Use when: (1) a git write op "takes forever" / never finishes; (2) `ps` shows the git process in interruptible sleep (STAT S/SN) with CPU TIME frozen across samples; (3) a stale 0-byte `.git/index.lock` is present; (4) `git push` stalls in "Counting objects" / `git repack -ad` hangs with an empty pack dir; (5) `git count-objects -v` shows thousands of loose objects and `packs: 0`; (6) the volume is near-full (`df` ~95%+); (7) `.git/index` went missing after an interrupted git op. Covers the plumbing-commit workaround (write-tree → commit-tree → update-ref) that bypasses the hanging working-tree refresh and hooks, index recovery via read-tree, and the real fixes.
Ships in git-workflow. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Routine git operations stall indefinitely and never return: git commit,
git reset, git gc, git repack, git push, even git status. The process
is not crashing or erroring — it is parked, blocked on I/O, consuming ~0% CPU.
Suspect this when one or more hold:
ps -axo pid,stat,etime,time,command | grep '[g]it' shows the git writer with
STAT S or SN (interruptible sleep) and CPU TIME frozen when sampled
twice a few seconds apart (no growth ⇒ blocked, not computing).
(Filter out gitstatusd and false matches like "Logitech".).git/index.lock exists and its mtime does not advance.git push stalls inside "Counting objects"; git repack -a -d also hangs
and leaves the pack dir empty. Both use git pack-objects.git count-objects -vH shows thousands of loose objects, packs: 0.df -h /System/Volumes/Data (macOS) shows the volume near-full (~95%+)..git/index is missing (only a 0-byte
index.lock remains).Filesystem I/O contention. git pack-objects must read every loose object, and
the index-refresh stat() scan must walk the whole working tree — both stall on a
pressured / near-full APFS volume. It is frequently triggered by a single large
commit/add (e.g. vendoring a big data directory) that simultaneously balloons
the loose-object count and the working-tree scan. Note: absolute free space can
look fine (e.g. 19 GB free) yet git still stalls — percent-full + APFS
contention matters more than raw bytes for this symptom. A hanging pre-commit /
commit-msg hook is a separate possible cause of git commit specifically.
ps -axo pid,stat,etime,time,command | grep '[g]it' | grep -v gitstatusd
sleep 4
ps -axo pid,stat,etime,time,command | grep '[g]it' | grep -v gitstatusd # TIME unchanged ⇒ stuck
git count-objects -vH # thousands loose / packs: 0
df -h /System/Volumes/Data # near-full?
SSH to the remote being fine confirms the hang is local (pack-objects/refresh), not the network.
kill <pid> # the parked git writer; kill -9 if needed. NEVER kill gitstatusd.
rm -f .git/index.lock
If git ran inside an agent/subprocess, stop that owner first so it can't race you.
.git/index is missing, rebuild it WITHOUT scanning the working treegit read-tree HEAD # repopulates the index from HEAD's tree; no working-tree scan
Do not use git reset to recover — it refreshes the index by scanning the
working tree and will re-hang.
This is the key workaround. It bypasses both the hanging working-tree refresh and
all hooks (commit-tree runs no hooks):
tree=$(git write-tree) # tree from the index, no WT scan
commit=$(git commit-tree "$tree" -p HEAD -m "your message")
git update-ref refs/heads/<branch> "$commit" # move the branch
Stage changes with index-only ops that don't scan the working tree
(git rm --cached, git update-index) where possible.
timeoutWrap every git call (timeout 120 git ...). If it exits 124, escalate / change
approach — do not retry the same command in a loop.
git status (it scans and can re-hang)git rev-parse HEAD
git rev-parse origin/main
git rev-list --left-right --count origin/main...HEAD # ahead/behind
git log --oneline -3
uv cache clean, brew cleanup, pip cache purge,
docker system prune (never --volumes).git gc / git repack -ad to consolidate loose objects
(→ 0 loose), making future ops fast.git log --oneline -3 shows your new commit on top
of the previous HEAD; git diff --cached --stat is empty (index == new HEAD).git gc and git push complete within their timeouts;
git count-objects -v shows packs: 1 and few/zero loose objects.Symptom: git commit for a 2,922-file vendored data dir parked in SN at 0% CPU
for 14 min, holding a 0-byte stale index.lock; .git/index later went missing;
git push then stalled in "Counting objects"; count-objects showed 3,213 loose /
0 packs on a 96%-full volume.
Recovery that worked: killed the parked PID, rm -f .git/index.lock,
git read-tree HEAD to rebuild the index, then
tree=$(git write-tree); commit=$(git commit-tree "$tree" -p HEAD -m "..."); git update-ref refs/heads/main "$commit" — commit landed instantly. The push
remained blocked until disk headroom was freed / the large data dir was dropped
from tracking (its objects then unreachable, leaving only a tiny pack to push).
gitstatusd (powerlevel10k / zsh git prompt) runs read-only and is NOT the
culprit; never kill it during recovery.git rm -r --cached .
— the working tree is byte-identical to HEAD, so re-adding (or git reset) is a
no-op versus HEAD, not real data loss..git/index is recoverable (it's a cache rebuilt from HEAD), not data
loss; commit objects and the working tree are unaffected.git-write-tree, git-commit-tree, git-update-ref,
git-read-tree, git-count-objects — https://git-scm.com/docsWhat SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub cajias/claude-skills --plugin git-workflow6 skills in this plugin
/gh-pr-create-must-push-errorFix for "aborted: you must first push the current branch to a remote, or
use the --head flag" from `gh pr create` when the branch IS already
pushed. Use when: (1) `git push -u origin <branch>` succeeded moments
earlier, (2) `git branch -vv` shows upstream tracking is set, (3) `gh pr
create` still rejects with the must-push message. Workaround: pass
`--head <branch>` explicitly.
/gh-pr-merge-in-worktreesRecover from `gh pr merge --delete-branch` appearing to fail inside a git
worktree. Use when: (1) `gh pr merge 2 --delete-branch` prints
`failed to run git: fatal: '<branch>' is already used by worktree at
'<path>'`, (2) you suspect the PR merged anyway despite the error,
(3) you see a merged PR with its remote branch still present on origin,
(4) working in any multi-worktree setup where `main` is checked out in
a sibling worktree. Explains that `gh pr merge --delete-branch` runs
three separable steps (API merge, local delete, remote delete) and the
middle step failing leaves the merge state inconsistent with the
branch-cleanup state.
/git-rebase-continue-editor-noninteractiveFix for `git rebase --continue` failing in non-interactive shells with
the misleading error `"there was a problem with the editor 'nano'"`
/ `"could not commit staged changes"`. Use when:
(1) you ran `git rebase --continue` after manually resolving a merge
conflict via `git add`, in a non-interactive context (CI workflow,
agent dispatch, ctx_execute, headless script), and the rebase
silently aborted instead of completing;
(2) the error output suggests using `-m`/`-F` but `git rebase
--continue` rejects those flags;
(3) `git status` shows the conflict-resolved files staged but
uncommitted, `git branch --show-current` is empty (detached HEAD),
and the rebase metadata under `.git/rebase-merge/` (or
`.git/worktrees/<wt>/rebase-merge/` for a worktree) is still present;
(4) you're scripting bulk-rebases across multiple PR branches and
one of them stalls on a manually-resolved conflict.
Root cause is `git rebase --continue` unconditionally opening
`$GIT_EDITOR` to confirm the commit message; there is no `--no-edit`
flag for `git rebase`. Fix is one env-var prefix:
`GIT_EDITOR=true git rebase --continue`.