Diagnose and bypass `gh pr merge --squash --delete-branch` failing with
"failed to run git: fatal: 'main' is already used by worktree at ..." when
another git worktree has main checked out. Use when: (1) you run gh pr merge
and see this exact error, (2) you have multiple worktrees in the repo (e.g.
`.claude/worktrees/*`), (3) the error appears even though the GitHub merge
itself looks fine. The merge SUCCEEDED on GitHub — only gh's local-side
effect (post-merge `git checkout main`) failed. Verify via
`gh pr view N --json state,mergedAt`; if state=MERGED, you're done. This
also applies to `gh pr checkout` and any other `gh` subcommand that tries
to touch the local main branch while another worktree has it claimed.
v1.2.0 (2026-05-26) adds the sequential-error variant: if you re-run from
the main-repo worktree after the first error, you can then hit "cannot
delete branch <feature-branch> used by worktree at <feature-worktree>" —
same one-checkout-per-branch invariant, this time applied to the feature
branch. Cleanup order: `git worktree remove` BEFORE `git branch -D`.
v1.3.0 (2026-05-27) adds the `--auto --delete-branch` enable-time
variant: when checks are still pending, `gh pr merge N --auto --squash
--delete-branch` fails locally (same "main is already used by worktree"
message) BEFORE the auto-merge intent is registered server-side —
`gh pr view N --json autoMergeRequest` returns null. Workaround: drop
`--delete-branch` (`gh pr merge N --auto --squash`), then `git worktree
remove` + `git branch -D` manually after the merge lands. The post-merge
variant in v1.0-1.2 succeeds the merge first then chokes on cleanup;
this v1.3 variant chokes BEFORE the server-side enable, so verifying
with `--json autoMergeRequest` (not just `state`) is required.
「EC と販売」の作業に使います。公開者の説明: Diagnose and bypass `gh pr merge --squash --delete-branch` failing with "failed to run git: fatal: 'main' is already used by worktree at ..." when another gi…
リクエスト例
“ストアの商品説明を更新して。”
エージェント
Claude Code, Codex, OpenCode ほか 32 エージェント 向けのコマンドがあります。
信頼できますか?
GitHub スター 5 · MIT。インストール前にソースを確認してください。
利用状況
過去 30 日間、サイトとエージェントでの利用。
0件のマイリストに登録
0回表示
0回コマンドをコピー
0回サイトからダウンロード
0回アプリからインストール
0回エージェントが自分でインストール
0人のアクティブユーザー
実利用スコアには ANG アプリから 20 人以上のユーザーと 50 件以上のタスクが必要です。現在 0 人、0 件。それまでは強さのスコアを掲載データから推定します。