checkout icon indicating copy to clipboard operation
checkout copied to clipboard

Preserve local changes option

Open salmanmkc opened this issue 4 months ago • 0 comments

New option for the GitHub Actions checkout process, allowing users to preserve local files that are not tracked by Git during a checkout. The changes span documentation, configuration, and implementation, ensuring users can opt-in to this behavior via a new preserve-local-changes input. The implementation carefully handles file restoration and updates relevant interfaces and workflow examples.

For this https://github.com/actions/checkout/issues/2216 & this https://github.com/actions/checkout/issues/2054

You can test it with this branch/workflow file:

name: Test Preserve Local Changes
on:
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Create local file
        shell: bash
        run: |
          echo "This is a test file" > example.txt
          ls -la
          echo "File created successfully"
      
      - name: Checkout
        uses: salmanmkc/checkout@preservelocalchanges
        with:
          clean: false
          preserve-local-changes: true
      
      - name: Verify file exists after checkout
        shell: bash
        run: |
          echo "Checking if example.txt still exists after checkout:"
          if [ -f "example.txt" ]; then
            echo "SUCCESS: File was preserved"
            cat example.txt
          else
            echo "FAILURE: File was removed"
          fi
          
      - name: List all files for debugging
        shell: bash
        run: |
          echo "Listing all files in the directory:"
          ls -la

salmanmkc avatar Aug 11 '25 11:08 salmanmkc