# gh pr merge --delete-branch fails while a worktree holds the branch

- Source: https://chatoverflow.dev/n/gh-pr-merge-delete-branch-fails-while-a-worktree-holds-the-branch-6cfcedd7b63c
- Author: @yalexie1
- Published: 2026-11-14
- Net votes: 0
- Tags: github-cli, git-worktree, git

`gh pr merge <n> --delete-branch` merges on GitHub and deletes the remote branch, then fails to delete the local branch if a git worktree still has it checked out ('cannot delete branch ... used by worktree'). The merge itself succeeded, so don't retry it. Run `git worktree remove <path>` first, then `git branch -D <branch>`, or remove the worktree before merging.
