# What Changed Between actions/checkout v4, v5, v6, and v7?

> Explore changes in actions/checkout v4, v5, v6, and v7. Discover security enhancements, isolated credentials, worktree support, and unsafe PR blocking for safer GitHub Actions.

- Repository: [GitHub Actions/checkout](https://github.com/actions/checkout)
- Tags: changelog
- Published: 2026-07-18

---

**The actions/checkout action evolved from v4 (Node 20 runtime) to v6 (Node 24 with isolated credential files and worktree support) and v7 (automated blocking of unsafe fork PRs), introducing security-hardened authentication and PR validation while maintaining backward-compatible sparse-checkout capabilities.**

The **actions/checkout** action is the standard method for accessing repository code within GitHub Actions workflows. While **v4** established the modern Node 20 runtime, subsequent versions introduced critical security architecture changes—including isolated credential handling in **v6** and automated blocking of untrusted fork PRs in **v7**—that fundamentally alter the security posture and flexibility of CI/CD pipelines according to the `actions/checkout` source code.

## Runtime and Dependency Upgrades

### Node.js Runtime Evolution

The underlying execution environment shifted across major versions, impacting compatibility and performance:

- **v4**: Updated to **Node 20** ([v4.0.0](https://github.com/actions/checkout/blob/main/CHANGELOG.md#v400))
- **v6**: Updated to **Node 24** with expanded support details in README ([v6.0.0](https://github.com/actions/checkout/blob/main/CHANGELOG.md#v600))
- **v7**: Continues on **Node 24** with no runtime change, focusing instead on security hardening and dependency hygiene

### Dependency Management

In **v4**, the action bumped npm packages and upgraded `@actions/core` & `@actions/tool-cache` ([v4.1.5–4.1.7](https://github.com/actions/checkout/blob/main/CHANGELOG.md#v415)). According to the source code, **v6** upgraded npm dependencies to support Node 24 and removed `uuid` in favor of native solutions, while **v7** continued with eslint 9 and CodeQL 4 updates without breaking API changes.

## Credential Architecture and Security

### Global Config vs Temporary Files (v4 vs v6)

In **v4**, the `persist-credentials` input wrote the authentication token directly into the repository’s global git config, creating potential exposure risks for downstream steps. In **v6**, as implemented in [`src/git-auth-helper.ts`](https://github.com/actions/checkout/blob/main/src/git-auth-helper.ts), credentials are written **to a separate temporary file** (`~/.git-credentials`) and explicitly cleaned up after checkout, preventing accidental credential leakage.

```yaml

# v4 style (still works but uses global config)

- uses: actions/checkout@v4
  with:
    fetch-depth: 0
    submodules: true

# v6 – secure credential handling

- uses: actions/checkout@v6
  with:
    persist-credentials: true   # Writes to temporary file, not global config

    path: repo-a
    token: ${{ secrets.GITHUB_TOKEN }}

```

### Worktree Support (v6.0.1)

Version **v6.0.1** introduced `includeIf`-based worktree handling in [`src/main.ts`](https://github.com/actions/checkout/blob/main/src/main.ts) and [`src/input-helper.ts`](https://github.com/actions/checkout/blob/main/src/input-helper.ts), allowing multiple repositories to be checked out in parallel while keeping credentials scoped per-worktree using conditional configuration.

## Unsafe PR Protection and Input Sanitization (v7)

### Blocking Fork PRs

**v7.0.0** introduced explicit blocking of unsafe PRs for `pull_request_target` and `workflow_run` contexts, implemented in [`src/unsafe-pr-checkout-helper.ts`](https://github.com/actions/checkout/blob/main/src/unsafe-pr-checkout-helper.ts). The action now validates the execution context and refuses to checkout untrusted fork PRs unless explicitly allowed, mitigating credential-exposure attacks from malicious pull requests.

### Input Sanitization

Version **v7.0.1** added **trimming of ASCII whitespace** for branch names and proper escaping of values passed to `--unset`, preventing injection attacks against git configuration commands.

```yaml

# v7 – automatic security blocking and normalization

- uses: actions/checkout@v7
  with:
    # No extra config needed; automatically refuses unsafe PRs

    # and normalizes branch names by trimming whitespace

    ref: ${{ github.event.pull_request.head.ref }}

```

## Sparse Checkout and Fetch Behavior

### Sparse Checkout Evolution

**v4.1.0** introduced support for partial checkout filters. This was refined in v4.1.2–v4.1.4 with Git-version guards that disable `sparse-checkout` when the option is missing. Versions **v6** and **v7** retain this stable behavior without further breaking changes to the feature.

### SHA-256 and Merge Commit Support

**v6.0.2 and v6.0.3** introduced SHA-256 repository support (fixing initialization for SHA-256 repos) and expanded merge-commit SHA regex patterns, improving compatibility with modern Git repositories using experimental hash algorithms.

## Key Source Files

The architectural shifts across versions are implemented in these critical files:

- [`action.yml`](https://github.com/actions/checkout/blob/main/action.yml) — Defines versioned inputs/outputs and default behaviors
- [`src/main.ts`](https://github.com/actions/checkout/blob/main/src/main.ts) — Orchestrates the checkout flow; contains worktree handling logic added in v6
- [`src/input-helper.ts`](https://github.com/actions/checkout/blob/main/src/input-helper.ts) — Parses `includeIf` conditions and `persist-credentials` inputs
- [`src/git-auth-helper.ts`](https://github.com/actions/checkout/blob/main/src/git-auth-helper.ts) — Implements temporary credential file isolation introduced in v6
- [`src/unsafe-pr-checkout-helper.ts`](https://github.com/actions/checkout/blob/main/src/unsafe-pr-checkout-helper.ts) — Implements PR-safety checks and context validation added in v7

## Summary

- **Runtime**: v4 uses Node 20; v6 and v7 use Node 24
- **Security**: v6 isolates credentials in temporary files instead of global git config; v7 automatically blocks unsafe fork PRs in sensitive contexts
- **Architecture**: v6 adds parallel worktree support via `includeIf`; v7 adds input sanitization for branch names
- **Compatibility**: Sparse checkout capabilities added in v4 remain stable across v6 and v7

## Frequently Asked Questions

### What is the main security difference between actions/checkout v6 and v7?

Version v6 focused on credential isolation by writing tokens to temporary files rather than global git config. Version v7 adds explicit blocking of unsafe pull requests from forks in `pull_request_target` and `workflow_run` contexts, preventing attackers from exfiltrating secrets through malicious PRs that spoof repository contexts.

### How does credential handling differ between v4 and v6?

In v4, enabling `persist-credentials` writes the authentication token directly into the global git configuration, where it remains visible to subsequent steps. In v6, the action writes credentials to a temporary file (`~/.git-credentials`) that is removed after checkout, significantly reducing the risk of accidental token exposure.

### Is there a runtime difference between v6 and v7?

No, both v6 and v7 run on Node 24. Version v7 focuses on security hardening, dependency updates (including eslint 9 and CodeQL 4), and input sanitization rather than runtime changes.

### When should I use sparse-checkout with these versions?

Sparse-checkout is supported from v4.1.0 onward and remains stable in v6 and v7. Use it when working with large monorepos to fetch only specific directories, reducing network overhead and checkout time. The feature requires Git version 2.25 or later, which the action validates automatically.