Skip to content

Backport action fails with "couldn't find remote ref" on existing branches #12809

Closed

Description

@offtherailz

Description

Applying a backport <branch> label sometimes makes the backport workflow fail with:

Backport failed for `2026.02.xx`: couldn't find remote ref `2026.02.xx`.
Please ensure that this GitHub repo has a branch named `2026.02.xx`.

even though the target branch exists.

Actual error

The message is misleading. korthout/backport-action reports it for any failure of the git fetch of the target branch. The real error in the run log is:

[command]/usr/bin/git fetch --depth=1 origin 2026.02.xx
fatal: shallow file has changed since we read it

Cause

.github/workflows/backport.yml checks out with the default fetch-depth: 1, so the working copy is a shallow clone. The action then performs its own shallow fetches, which rewrite .git/shallow:

  1. git fetch --depth=<n> origin refs/pull/<pr>/head
  2. git fetch --depth=2 origin +<sha>:refs/remotes/origin/<sha>
  3. git fetch --depth=1 origin <target-branch> -> fails

The more the repository has to be deepened (older PRs, PRs with many commits), the more likely the failure.

Steps to reproduce

Apply a backport 2026.02.xx label to an older merged pull request with several commits, e.g. #12557.

Expected

The backport pull request is created.

Proposed fix

Check out the full history without blobs, so there is no shallow file at all.

Activity

  1. self-assigned this
    on Aug 17, 2026
  2. added theissue type on Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions