GitHub sync: headRefName returns refs/pull/N/head, and branches differ from GitHub #652
Summary#
On a repository synced from GitHub, src pr view N --json headRefName returns refs/pull/N/head for most pull requests, where gh returns the branch name. Tooling written for gh uses headRefName as a branch name and breaks.
Separately, the branches of the repository on Source do not match GitHub. The refs/pull/N/head refs do match.
Both could be by design. If they are, please say so and I will close this.
Repository: TanStack/ai. Measured on 2026-11-21 with git ls-remote against both hosts, gh pr list and src pr view.
1. headRefName is a pull ref, not a branch#
Of 46 open pull requests on Source, 39 return refs/pull/N/head.
Compared with the 45 that are open on GitHub:
| Count | GitHub says | Source headRefName | Head branch on Source |
|---|---|---|---|
| 24 | from a fork | refs/pull/N/head | not there |
| 6 | same repository | branch name | same commit as GitHub |
| 4 | same repository | refs/pull/N/head | same commit as GitHub |
| 6 | same repository | refs/pull/N/head | not there |
| 5 | same repository | refs/pull/N/head | older commit than GitHub |
Examples:
- #979: branch
taren/workflow-orchestration-rfc, Source returns the branch name. This is the result I expect. - #1955: branch
1935-ai-harness-rejected-receipt-resolves-before-durable-rejection-recovery-can-rerun-the-inputis on Source at the same commit as GitHub, butheadRefNameisrefs/pull/1955/head. - #2067: branch
chore/renovate-all-depsis not on Source.headRefNameisrefs/pull/2067/head. - #1896: branch
openui-tier-fis on Source at7402cf3. GitHub's head is463b7f8.headRefNameisrefs/pull/1896/head.
The 4 pull requests in row three show that a missing branch does not explain every case.
For a pull request from a fork, gh returns the branch name of the fork (for example fix/after-tool-hook-error for #1559).
Effect#
A script that does git worktree add <path> "$headRefName", or names a local branch or a directory from it, fails. My review launcher opened 2 of 5 pull requests for this reason.
Wanted#
headRefName returns the branch name that GitHub has, also for a pull request from a fork. If the pull ref is useful, give it in a different field.
2. Branches differ from GitHub#
| Source | GitHub | |
|---|---|---|
| Branches | 165 | 152 |
| Only on this host | 22 | 9 |
| Same name, different commit | 6 | 6 |
refs/pull/N/head | 1,668 | 1,668 |
refs/pull/N/head with a different commit | 0 | 0 |
| Tags (measured 2026-11-19) | 5,748 | 5,748, all the same |
main is the same on both.
Branches only on Source are possibly correct: they can be pull requests that stay on Source. The branches only on GitHub (9) and the ones at an older commit on Source (6) look like sync that did not run. Five of those six are the head of an open pull request (table above).
Wanted#
One of these:
- Sync brings each branch of GitHub to Source and keeps it current, or
- the docs say that only release branches and pull refs sync, and
headRefNamestill gives the branch name.
Not checked#
My login is not an admin of TanStack/ai, so src github-sync status is refused. I do not know the release branches, the warnings, or if sync is paused.
tombeckenham assignedtombeckenham
Sign in to join this conversation.