gh-pr-merge-in-worktrees

Diagnose failed gh pr merge --delete-branch operations in git worktrees.

Updated Nov 18, 2025
One-click install
npx skills add https://github.com/cajias/claude-skills --skill gh-pr-merge-in-worktrees
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gh-pr-merge-in-worktrees
Source: https://github.com/cajias/claude-skills/tree/main/plugins/git-workflow/skills/gh-pr-merge-in-worktrees
Command: npx skills add https://github.com/cajias/claude-skills --skill gh-pr-merge-in-worktrees

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you recover when gh pr merge --delete-branch appears to fail in a git worktree, even though the pull request may already be merged.

Core Features & Use Cases

  • Diagnose the real merge state: Confirms whether the GitHub PR merge succeeded when the local cleanup step failed.
  • Separate merge from branch cleanup: Explains the three-step behavior of merge, local branch deletion, and remote branch deletion.
  • Worktree-safe recovery: Shows how to remove the remote branch manually and avoid risky local branch deletion in multi-worktree setups.
  • Use Case: You merge a PR from a sibling worktree, see a fatal branch-in-use error, and need to verify the merge before cleaning up the remote branch safely.

Quick Start

Ask me to verify whether a failed gh pr merge --delete-branch actually merged the pull request and tell me the safest cleanup steps for the remaining branch.

Frequently Asked Questions about gh-pr-merge-in-worktrees

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does gh pr merge --delete-branch fail in a git worktree?

The gh pr merge --delete-branch command fails in git worktrees because the local branch deletion step encounters a branch-in-use error when the base branch is checked out in another worktree, even though the remote PR merge may have already succeeded.

How do I check if a GitHub PR merged after a worktree delete error?

To check if a GitHub PR merged after a worktree delete error, verify the PR state and mergedAt metadata on GitHub using the gh CLI, which confirms the merge succeeded independently of the local branch cleanup failure.

What is the safest way to delete a remote branch after a failed gh pr merge in a worktree?

The safest way to delete a remote branch after a failed gh pr merge is to manually remove the remote branch using git push origin --delete, avoiding risky local branch deletion in multi-worktree setups where the base branch is active elsewhere.

Can I use gh pr merge --delete-branch in multi-worktree workflows without errors?

Using gh pr merge --delete-branch in multi-worktree workflows often triggers errors because the command attempts local branch deletion while the branch is checked out in a sibling worktree, causing a fatal branch-in-use conflict during the cleanup phase.

Does gh pr merge --delete-branch separate the PR merge from branch cleanup?

Yes, gh pr merge --delete-branch operates in three distinct steps: merging the PR, deleting the local branch, and deleting the remote branch. A failure in branch cleanup does not mean the PR merge itself failed, as these steps are independent.

How do I recover from a fatal branch-in-use error during git worktree branch deletion?

To recover from a fatal branch-in-use error during git worktree branch deletion, first confirm the GitHub PR merge succeeded by checking mergedAt metadata, then manually delete the remote branch without forcing local branch removal in the active worktree.