Skip to content

fetch-depth: 0 no longer sets up origin/HEAD after Git 2.50 update #2219

Open
@idan-rahamim-lendbuzz

Description

@idan-rahamim-lendbuzz

Issue Description

Summary

Following the update of the ubuntu24/20250710.1 runner image—which included upgrading Git from 2.49.0 to 2.50.1—using actions/checkout@v4 with fetch-depth: 0 no longer sets up the origin/HEAD symbolic reference. As a result, workflows that rely on origin/HEAD..HEAD as a valid revision range are now broken.


Steps to Reproduce

  1. Use actions/checkout@v4 with fetch-depth: 0 on an ubuntu-latest runner.
  2. Execute a command referencing origin/HEAD (e.g., git diff origin/HEAD..HEAD).
  3. Observe the following error:
    fatal: ambiguous argument 'origin/HEAD..HEAD': unknown revision or path not in the working tree
    

Expected Behavior

  • The origin/HEAD symbolic ref should automatically point to the default branch, mirroring the behavior of a standard git clone.

Actual Behavior

  • The origin/HEAD reference is missing, causing failures in tools and scripts that rely on it (for example, pre-commit when invoked with --from-ref origin/HEAD --to-ref HEAD).

Environment

  • Runner: ubuntu-latest (ubuntu24/20250710.1)
  • Git version: 2.50.1 (previously 2.49.0)
  • Checkout version: actions/checkout@v4

Example Workflow

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - run: git diff origin/HEAD..HEAD

Workaround

Adding the following step immediately after checkout restores the expected behavior:

- name: Set up git references
  run: git remote set-head origin --auto

Root Cause

Git 2.50 introduced changes to default branch handling during clone operations, which appears to affect how origin/HEAD is configured.


Request

Please update actions/checkout to ensure that origin/HEAD is correctly set when fetch-depth: 0 is used, maintaining compatibility with workflows that depend on this reference.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions