Skip to content

docs(runbooks): PR creation from linked worktrees (ag-9zls #worktree-pr-runbook)#775

Draft
boshu2 wants to merge 1 commit into
mainfrom
docs/ag-9zls-worktree-pr-runbook
Draft

docs(runbooks): PR creation from linked worktrees (ag-9zls #worktree-pr-runbook)#775
boshu2 wants to merge 1 commit into
mainfrom
docs/ag-9zls-worktree-pr-runbook

Conversation

@boshu2
Copy link
Copy Markdown
Owner

@boshu2 boshu2 commented Jun 6, 2026

What

Adds docs/runbooks/pr-creation-from-linked-worktrees.md — root cause + verified fix for the background-agent bug ag-9zls: "No branch name available for PR creation" from linked-worktree branches.

Root cause (verified live)

git worktree add -b <branch> origin/main inherits upstream tracking from the start point, so branch.<branch>.merge = refs/heads/main. Any PR tool that infers the head from upstream config resolves it to main → no distinct head → the error. The branch is pushed and real; only the inferred head is wrong.

BEFORE push -u:  branch.<b>.merge = refs/heads/main      @{u} = origin/main
AFTER  push -u:  branch.<b>.merge = refs/heads/<b>       @{u} = origin/<b>

Fix

git push -u origin HEAD:<branch> rewrites tracking to the branch itself; always pass --head <branch> to PR creation. Runbook gives a three-tier path (gh --head / gh api / compare-URL fallback for no-write-token agents) plus prevention.

Evidence

This PR was itself opened from the linked worktree docs/ag-9zls-worktree-pr-runbook using the documented Tier-1 path — the before/after tracking flip was captured live.

Checks

  • markdownlint (repo .markdownlint.json): pass
  • Indexed in docs/documentation-index.md

Closes-scenario: ag-9zls#worktree-pr-runbook
Bounded-context: BC5-Runtime
Evidence: docs/runbooks/pr-creation-from-linked-worktrees.md

…ls #worktree-pr-runbook)

Document the verified root cause of 'No branch name available for PR
creation' from linked-worktree branches: 'git worktree add -b <b>
origin/main' inherits upstream tracking from main, so branch.<b>.merge =
refs/heads/main and any PR tool that infers head from upstream resolves it
to main. Fix: 'git push -u origin HEAD:<b>' rewrites tracking to the branch.

Adds a three-tier PR-creation path (gh --head / gh api / compare-URL) that
never relies on head inference, plus prevention options. Validated live in
this repo; index entry added.

Closes-scenario: ag-9zls#worktree-pr-runbook
Bounded-context: BC5-Runtime
Evidence: docs/runbooks/pr-creation-from-linked-worktrees.md
@github-actions github-actions Bot added the docs label Jun 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant