Skip to content

gh pr merge fails when running from a worktree #3

@avifenesh

Description

@avifenesh

Problem

When /ship runs from a git worktree (created by /next-task Phase 3), the merge phase fails because gh pr merge --delete-branch tries to checkout main locally, which is already locked by the main worktree.

failed to run git: fatal: 'main' is already used by worktree at 'C:/Users/avife/agent-sh/web-ctl'

Steps to Reproduce

  1. /next-task creates a worktree at ../worktrees/web-ctl-fix-XXX
  2. Implementation and PR creation happen from the worktree
  3. ship:ship runs gh pr merge N --squash --delete-branch from the worktree
  4. gh tries to git checkout main after merge - fails because main is used by the main worktree
  5. Workaround: run gh pr merge from the main repo directory instead

Expected

Phase 6 (merge) should detect it's running inside a worktree and handle this automatically - either by using gh pr merge --repo owner/repo without local checkout, or by switching to the main repo path before merging.

Frequency

This will happen every time /next-task is used, since it always creates worktrees.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions