Diagnose and bypass `gh pr merge --squash --delete-branch` failing with
"failed to run git: fatal: 'main' is already used by worktree at .…
A skill in “E-commerce and sales”. Ready commands for Claude Code, Codex, OpenCode and 32 more agents.
Full description
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.
Skill
E-commerce and sales
35 agents
5 stars
MIT
This entry comes from the GitSkills open dataset (CC-BY-4.0). ANG did not run or audit this skill; check the source before installing.
AiderNo SKILL.md support documented for Aider.Source
PlandexNo SKILL.md support documented for Plandex.Source
CodeGPTNo SKILL.md support documented for CodeGPT.Source
SWE-agentNo SKILL.md support documented for SWE-agent.Source
mini-SWE-agentNo SKILL.md support documented for mini-SWE-agent.Source
JulesNo SKILL.md support documented for Jules.Source
Open SWENo SKILL.md support documented for Open SWE.Source
GitLab DuoNo SKILL.md support documented for GitLab Duo.Source
Support comes from each agent’s official docs on SKILL.md and MCP; ANG has not run this entry on every agent.
In plain words
No tech background needed.
What is it?
A skill is a pack of instructions you load into your agent (like Claude Code or Codex). It is like installing an app on your phone: install it once and the agent knows how to do that job.
What is it for?
Used for “E-commerce and sales” work. In the publisher’s words: 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…
Example request
“Update the product descriptions in the store.”
Agents
Ready commands for Claude Code, Codex, OpenCode and 32 more agents.
Can I trust it?
5 GitHub stars · MIT. Check the source before installing.
Usage
Last 30 days, on the site and in agents.
0on shelves
0views
0commands copied
0site downloads
0installed from the app
0installed by the agent
0active users
A field score needs at least 20 users and 50 tasks from the ANG app; now 0 users, 0 tasks. Until then the power score is estimated from listing data.