Skip to content

Fetching new remote branch fails in multi-revision mode #6732

@robsyme

Description

@robsyme

Expected behavior and actual behavior

Expected: When running a pipeline with -revision where the branch exists on the remote repository, Nextflow should fetch and checkout that branch successfully.

Actual: When using the multi-revision repository strategy (default since ~25.x), attempting to pull a branch that exists on the remote but hasn't been fetched locally fails with the error:

Remote does not have <branch-name> available for fetch.

This only affects branches that exist on the remote but are not yet present in the local bare repository. Once a branch has been fetched at least once, subsequent pulls work correctly.

Steps to reproduce the problem

  1. Ensure you're using a recent Nextflow version with multi-revision mode enabled (default)
  2. Try to run or pull a pipeline with a branch that you haven't fetched before:

Clear any cached repos to ensure fresh state

rm -rf ~/.nextflow/assets/nf-core ~/.nextflow/.repos/nf-core

Try to pull a branch that exists on the remote

nextflow pull nf-core/fetchngs -revision preview-26-04

Or with any GitHub repository that has a branch not yet fetched:

nextflow run nf-core/fetchngs -revision preview-26-04

Program output

N E X T F L O W  ~  version 25.12.0-edge

Pulling nf-core/fetchngs:preview-26-04 ...
Remote does not have preview-26-04 available for fetch.

Environment

  • Nextflow version: 25.12.0-edge (and likely earlier versions with multi-revision mode)
  • Java version: 21
  • Operating system: macOS / Linux
  • Bash version: N/A (not bash-related)

Additional context

Root cause: In MultiRevisionRepositoryStrategy.refSpecForName(), when determining the correct RefSpec for fetching, the code only checks local refs in the
bare repository:

Ref branch = getBareGit().getRepository().findRef("refs/heads/" + revision)

For a new branch that doesn't exist locally, this returns null, causing the method to fall through and treat the branch name as a commit SHA:

return new RefSpec(revision + ":refs/tags/" + revision)

This creates an invalid RefSpec like preview-26-04:refs/tags/preview-26-04, which JGit fails to fetch because there's no commit with that literal name.

Fix: The method should query remote refs via lsRemote() when the revision is not found locally, before falling back to treating it as a commit SHA.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions