Skip to content

Conversation

@bonaert
Copy link

@bonaert bonaert commented Apr 10, 2025

See: #862

Adds a exclude_from_clean option, which excludes the specified path from the clean operation. More concretely, if a value is provided, the action runs git clean -ffdx -e <exclude_from_clean> && git reset --hard HEAD instead of running git clean -ffdx && git reset --hard HEAD.

This is particularly useful for self-hosted runners, where deleting and re-creating certain directories can sometimes be inneficient and costly (examples: node_modules, git LFS files)

@chtaili216
Copy link

gh pr checkout 2141

@kvz
Copy link

kvz commented Nov 30, 2025

This is my workaround:

    steps:
      - uses: actions/checkout@v4
        with:
          clean: false

      - name: Git Clean
        # While we use actions/checkout@v4 does not have a clean-exclude option,
        # we disable the default clean behavior and do it ourselves.
        # https://github.com/actions/checkout/issues/862
        run: ./_scripts/gitclean.sh

On our self-hosted runners where we need some directories to persist. But would love to have this natively supported 👐

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants