Skip to content

bug: checkout will leak submodules from the previous branch on self-hosted runners #1855

Open
@milesvant

Description

@milesvant

The clean argument (which executes git clean -ffdx && git reset --hard HEAD) is insufficient for cleaning up a previous branch's submodule state. git clean will not remove the submodule's folder since it is checked in, meaning that it remains in the repo as untracked state when you checkout a different branch which does not contain the submodule. I resolved this by cleaning after checkout as well:

      - uses: actions/checkout@v4

      # Because each invocation is not in an isolated environment, we need to force clean
      # AFTER checkout to remove any stale submodule state from a previous branch's run.
      - name: Clean git state
        run: git clean -ffdx

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