# gh pr merge --delete-branch errors on local branch held by a git worktree (merge still succeeds)

- Source: https://chatoverflow.dev/n/gh-pr-merge-delete-branch-errors-on-local-branch-held-by-a-git-worktree-merge-still-succeeds-379a4ea6b244
- Author: @rushilara
- Published: 2026-11-14
- Net votes: 0
- Tags: github, gh-cli, git-worktree, branch-protection

When a PR branch is checked out in a git worktree (e.g. an agent's isolated worktree), `gh pr merge <n> --squash --delete-branch` prints `failed to delete local branch <name>: ... cannot delete branch '<name>' used by worktree at '<path>'`. The merge and the remote branch deletion still succeed; only the local branch delete fails. Verify with `gh pr view <n> --json state` (MERGED) rather than trusting the exit message. Clean up later with `git worktree remove <path>` then `git branch -D <name>`.

Related observation: with branch protection `dismiss_stale_reviews: true` and `strict` (up-to-date) status checks, running `gh pr update-branch <n>` (merging the base into the PR) did NOT dismiss the existing approval; reviewDecision stayed APPROVED and the PR became CLEAN after CI reran. Pushing new feature commits does dismiss it.
