fix: disambiguate sync-from-public branch checkout#1235
Merged
Conversation
After 'git remote add public' fetches the same branches that already exist
on origin, 'git checkout <branch>' becomes ambiguous and fails with:
fatal: 'preview' matched multiple (2) remote tracking branches
Both sync jobs now use 'git checkout -B <branch> origin/<branch>' which
explicitly resets the local branch from origin's tracking ref, removing
the ambiguity and combining the previous 'checkout + reset --hard' into
one step.
Last 4 scheduled runs of 'Sync from Public Repo' all failed with this
error; the workflow has been silently broken since the public/origin
branches collided.
Contributor
Package TarballHow to installnpm install https://github.com/aws/agentcore-cli/releases/download/pr-1235-tarball/aws-agentcore-0.13.1.tgz |
agentcore-cli-automation
approved these changes
May 13, 2026
agentcore-cli-automation
left a comment
There was a problem hiding this comment.
Looks good to merge. The diagnosis is accurate — git fetch public main populates refs/remotes/public/main (since git remote add installs the default +refs/heads/*:refs/remotes/public/* fetch refspec), so once both origin and public have a main/preview ref, DWIM git checkout <branch> becomes ambiguous and fails. git checkout -B <branch> origin/<branch> sidesteps DWIM by giving git an explicit start point, and it preserves the original semantics (force-create-or-reset local branch to origin/<branch>) while collapsing two commands into one. Symmetric application to both jobs is correct. No test or telemetry concerns since this is CI infra.
Contributor
Coverage Report
|
notgitika
added a commit
that referenced
this pull request
May 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The `Sync from Public Repo` workflow has been silently failing on every scheduled run (every 6h) since the public-origin branch collision started. This PR fixes the underlying `git` ambiguity.
Root cause
Each job runs:
```bash
git remote add public https://github.com/aws/agentcore-cli.git
git fetch public main # or 'preview'
...
git checkout main # ← ambiguous!
```
After fetching, both `origin` and `public` have a branch named `main` (and `preview`), so the DWIM shortcut `git checkout main` fails:
```
fatal: 'preview' matched multiple (2) remote tracking branches
##[error]Process completed with exit code 128.
```
Recent failures (all caused by this):
Fix
Replace `git checkout ` + `git reset --hard origin/` with `git checkout -B origin/` in both jobs. `-B` creates or resets the local branch from an explicit ref, sidestepping the DWIM ambiguity entirely and consolidating two steps into one.
Why now
Before the App-token rollout (5767d93), the same workflow already had this latent bug — but at that time the public mirror was lagging behind, so the `merge-base --is-ancestor` short-circuit kept hiding it. Once the repos drifted, every run started hitting the failed `checkout`.
Test plan