# actions/checkout: every input and every major version, v4 to v7

All 21 actions/checkout inputs with their defaults and when to change each, what v5, v6 and v7 changed, and what @v4 runs today. The inputs that decide what lands on disk, run on v4 to v7.

By Grant Unwin, published 2026-11-03. Checked against GitHub's documentation on 2026-11-17. The web page: https://www.runners.io/blog/actions-checkout-every-input-v4-to-v7

actions/checkout has 21 inputs and 2 outputs, and v7.0.1 is its current release. Leave most inputs alone. Change fetch-depth when a job reads history, persist-credentials when it does not push, and sparse-checkout when the repository is large. A workflow on @v4, @v5 or @v6 is not on old behaviour: those tags moved on 20 July 2026 to releases that refuse to check out a fork pull request’s code under pull\_request\_target, as v7 does.

**In short**

- v7.0.1 is the current release, with 21 inputs and two outputs, ref and commit; every default is in the table.
- @v4, @v5 and @v6 now run v4.4.0, v5.1.0 and v6.1.0, from 20 July 2026, which refuse fork pull request code under pull\_request\_target.
- Change fetch-depth when a job reads history, persist-credentials when it does not push, and sparse-checkout when the repository is large.
- In our run, fetch-tags with fetch-depth 1 fetched no tags on v4.4.0 and v5.1.0, and all 68 on v6.1.0 and v7.0.1.
- v6 moved the token from .git/config to a file in the runner's temp directory; persist-credentials: false writes neither.

This is a reference for the whole action as it stands on the date this post was last checked, built from GitHub’s own files and from a workflow we ran on a GitHub-hosted runner against each major version. Where a statement comes from the run and not from GitHub, it says so.

## Which version does @v4 run today?

A floating major tag such as `@v4` is a moving pointer to the newest release of that major. On the date this post was last checked, each one points at a release published on 20 July 2026. GitHub’s changelog says workflows pinned to a floating major tag pick the backport up automatically, and that a SHA, minor or patch pin does not. So the table shows what each tag runs, and the change in each major that can break a workflow.

| Tag | The tag runs | Runtime | First release of the major | What can break a workflow |
| --- | --- | --- | --- | --- |
| v4 | v4.4.0, 20 July 2026 | node20 | v4.0.0, 17 October 2023 | v4.4.0 adds allow-unsafe-pr-checkout and, with it, the refusal to check out a fork pull request's code under pull\_request\_target and workflow\_run. |
| v5 | v5.1.0, 20 July 2026 | node24 | v5.0.0, 11 August 2025 | v5.0.0 needs runner 2.327.1 or later, because it runs on Node 24. v5.1.0 adds the fork refusal. |
| v6 | v6.1.0, 20 July 2026 | node24 | v6.0.0, 20 November 2025 | v6.0.0 keeps the token in a file under the runner's temp directory, not in .git/config. Container actions that run authenticated git need runner 2.329.0 or later. v6.1.0 adds the fork refusal. |
| v7 | v7.0.1, 20 July 2026 | node24 | v7.0.0, 18 June 2026 | v7.0.0 refuses a fork pull request's code under pull\_request\_target and workflow\_run unless allow-unsafe-pr-checkout is true. |

Older majors got the same backport: v3.7.0 and v2.8.0 carry the same release note, and GitHub says v1 does not. The runtime column is read from `action.yml` at each tag. We also checked it on the runner, by reading the action’s own file in the runner’s actions folder: node20 for v4 and node24 for v5, v6 and v7.

## Every input, with its default

The defaults are GitHub’s, read from `action.yml` at v7.0.1. The last column is the earliest release tag whose own `action.yml` lists the input; we read it from all 58 release tags. Every input in the table is in v7.

| Input | Default | What it does | Change it when | First tag with it |
| --- | --- | --- | --- | --- |
| repository | the repository that triggered the run | Which repository to check out, as owner/name. | You need a second repository. Give it a path so it does not overwrite the first. | v1.0.0 |
| ref | the event's own ref or SHA; the default branch for any other repository | The branch, tag or SHA to check out. | You build something other than the event's commit, such as a pull request's head. | v1.0.0 |
| token | github.token | The token used to fetch, and kept for later git commands unless persist-credentials is false. | The repository is private and not the one running, or a push must be made as someone other than the workflow. | v1.0.0 |
| ssh-key | none | An SSH key to fetch the repository with. | A deploy key is how the repository is reached. | v2.1.0 |
| ssh-known-hosts | none | Host keys to trust besides the user's and github.com's, which is always added. | The remote is not github.com. | v2.1.0 |
| ssh-strict | true | Whether to check the host key strictly (StrictHostKeyChecking=yes and CheckHostIP=no). | Almost never. Add the host to ssh-known-hosts instead. | v2.1.0 |
| ssh-user | git | The user to connect to the SSH host as. | The host does not use git as its user. | v4.1.3 |
| persist-credentials | true | Whether to leave the token or SSH key in the local git config for later commands. | The job does not push or fetch after the checkout. Set it to false. | v2.0.0 |
| path | the workspace root | Where under the workspace to put the repository. | More than one checkout in a job. | v1.0.0 |
| clean | true | Runs git clean -ffdx and git reset --hard HEAD before fetching. | The workspace already holds files you want kept. Otherwise leave it. | v1.0.0 |
| filter | none | A partial clone filter such as blob:none or tree:0. When it is set, it replaces the blob:none that sparse-checkout otherwise uses. | A large repository where the job needs history but not every file's contents. | v4.1.0 |
| sparse-checkout | none | Patterns, one per line, of what to write to disk. It also fetches with blob:none unless filter says otherwise. | A monorepo job that needs a few directories. | v3.5.3 |
| sparse-checkout-cone-mode | true | Whether the patterns are directories (cone mode) or git's older pattern syntax. | You need one file rather than a directory. Set it to false. | v3.5.3 |
| fetch-depth | 1 | How many commits to fetch. 0 means all history for all branches and tags. | The job reads history: a version from git describe, a changelog, blame, a diff against an earlier commit. | v1.0.0 |
| fetch-tags | false | Fetch tags even when fetch-depth is above 0. | The job needs tags and not the history behind them. See the test below before relying on it in v4 or v5. | v3.6.0 |
| show-progress | true | Whether to print git's progress lines while fetching. | The log is long and nobody reads the percentages. | v4.0.0 |
| lfs | false | Whether to download Git LFS files. | The repository stores large files with LFS and the job needs them. | v1.0.0 |
| submodules | false | true checks out submodules, recursive checks out their submodules too. | The repository has submodules the job builds. | v1.0.0 |
| set-safe-directory | true | Adds the repository path to git's safe.directory list in the global config. | You manage safe.directory yourself. | v2.4.2 |
| github-server-url | the server the workflow runs on | The base URL of the GitHub instance to clone from. | The repository is on another GitHub instance, such as GitHub Enterprise Server. | v3.1.0 |
| allow-unsafe-pr-checkout | false | Allows checking out a fork pull request's code from a pull\_request\_target or workflow\_run workflow. | You have read GitHub's guidance on those events and decided the job must run the fork's code. | v2.8.0 (v4.4.0, v5.1.0, v6.1.0 and v7.0.0 in the current majors) |

The two outputs are `ref`, the branch, tag or SHA that was checked out, and `commit`, the SHA. Both arrived in v4.2.0. In our run `commit` matched the checked-out HEAD on every version. `ref` was `refs/heads/main` when we took the default branch and empty when we passed a SHA as `ref`, which was most of our cases.

## What to change, by what the job does

Start from the job, not the input. This table is the short form of the sections below, with the setting we would put in each case.

| The job | Set | Why |
| --- | --- | --- |
| Reads history: git describe, a version from tags, a changelog, blame | fetch-depth: 0 | All history for all branches and tags. The cost is in the study linked at the end. |
| Compares with the commit before | fetch-depth: 2, then git checkout HEAD^ | GitHub's own example for it. |
| Needs tags but not history | fetch-tags: true with fetch-depth: 1 | Works on v6 and v7 in our run. On v4.4.0 and v5.1.0 it fetched none. |
| Needs one directory of a large repository | sparse-checkout: the directory | Cone mode by default, and it fetches with blob:none. |
| Needs one file | sparse-checkout: the path, with sparse-checkout-cone-mode: false | The root files and directories are not added. |
| Does not push | persist-credentials: false | No token is left in the workspace for later steps. |
| Pushes a commit from a pull request | ref: ${{ github.head\_ref }} | A pull request run checks out a detached merge commit, so the branch must be named. |
| Builds the pull request's own commit | ref: ${{ github.event.pull\_request.head.sha }} | Otherwise it builds the merge of the head and the base. |
| Needs a second, private repository | repository, token and path | github.token is scoped to the current repository. |
| Has submodules | submodules: recursive | Use true if the submodules have none of their own. |

On a `pull_request` run, GitHub says the commit that triggered the workflow is the last merge commit on the pull request’s merge branch. A plain checkout therefore builds the result of merging the head into the base, which is usually what a test should run against. If you want the pull request’s own commit, name it.

## fetch-depth: what 1, 2 and 0 leave in the repository

The default, `fetch-depth: 1`, fetches one commit. We checked out actions/checkout itself, pinned at its v7.0.1 commit, with each setting on each major version. The default left 1 commit and no tags. `fetch-depth: 2` left 2. `fetch-depth: 0` left 234 commits and 68 tags, and the repository stopped being shallow. The numbers were the same on v4, v5, v6 and v7. The point is the cost: 0 is the setting that downloads the history, and most jobs do not read it.

```yaml
- uses: actions/checkout@v7
  with:
    fetch-depth: 0   # all history for all branches and tags
- run: git describe --tags
```

Tools that need history are the ones that fail quietly with the default: a version computed from tags, a changelog generator, `git blame`, a diff against the previous release. With a one-commit checkout, `git describe --tags` exits with an error and `HEAD~1` does not exist. Our [timing post](https://www.runners.io/blog/how-long-does-actions-checkout-take) measures what each setting costs on six public repositories, and says what broke.

## fetch-tags: a difference between versions that we measured

`fetch-tags: true` is documented as fetching tags even when `fetch-depth` is above 0. In our run it did not on the two older majors. With a depth of 1 and `fetch-tags: true`, `@v4` (v4.4.0) and `@v5` (v5.1.0) left no tags, whether we named a commit or took the default branch. `@v6` (v6.1.0) and `@v7` (v7.0.1) left all 68. The changelog’s entry for v6.0.2, “Fix tag handling: preserve annotations and explicit fetch-tags”, is the likely reason, though we did not read the code to confirm it. It is one repository and one tag count, so test your own before you rely on it.

```yaml
- uses: actions/checkout@v7
  with:
    fetch-depth: 1
    fetch-tags: true
- run: git tag | wc -l   # 68 on v6 and v7 in our run, 0 on v4 and v5
```

## sparse-checkout and filter: fetch less, write less

The README says `filter` “overrides sparse-checkout if set”. The code is more precise. A sparse checkout fetches with `filter=blob:none` on its own, so the file contents it does not write are not downloaded. If you also set `filter`, that value is used for the fetch in place of `blob:none`, and the sparse patterns still apply. In our run `sparse-checkout: src` left 37 of the repository’s 101 files on disk and a `blob:none` filter in the git config, and a single file with `sparse-checkout-cone-mode: false` left 1.

```yaml
# a directory, plus the files in the repository root
- uses: actions/checkout@v7
  with:
    sparse-checkout: |
      src

# one file, and nothing else
- uses: actions/checkout@v7
  with:
    sparse-checkout: README.md
    sparse-checkout-cone-mode: false

# all history, no file contents until git asks for them
- uses: actions/checkout@v7
  with:
    fetch-depth: 0
    filter: blob:none
```

A partial clone moves cost rather than removing it: the first command that needs a file’s contents fetches them then, over the network, in the middle of your job.

## persist-credentials: where the token ends up

By default the checkout leaves its token configured so your later `git push` and `git fetch` work, and its post-job step removes it. What changed between majors is where it sits. On our run, `@v4` and `@v5` wrote an `http.https://github.com/.extraheader` entry into the repository’s `.git/config`. `@v6` and `@v7` wrote no such entry; they added four `includeIf` entries that point to a separate file in the runner’s temp directory. GitHub describes v6 the same way. With `persist-credentials: false` none of these were written on any version.

```yaml
permissions:
  contents: read
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
        with:
          persist-credentials: false   # this job never pushes
      - run: make test
```

GitHub recommends the token’s `contents: read` permission for the checkout unless you give it a different token or key. Setting `persist-credentials: false` in a job that does not push means a later step has no token to find, in `.git/config` or anywhere else the action put it.

## pull\_request\_target, workflow\_run and allow-unsafe-pr-checkout

`pull_request_target` runs in the context of the base repository’s default branch, with its token and secrets. Checking out a fork’s pull request there is the pattern GitHub calls a “pwn request”, and from 18 June 2026 v7 refuses it by default. It refuses when the pull request is from a fork and `repository` names the fork, or `ref` is `refs/pull/N/head` or `refs/pull/N/merge`, or `ref` is a fork pull request’s head or merge commit SHA. For `workflow_run` it applies only when the triggering event was a pull request event. Pull requests from the same repository, and the `pull_request` event, are not affected.

These are the three patterns it blocks, as GitHub lists them:

```yaml
on: pull_request_target
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      # each of these three steps is refused for a pull request from a fork
      - uses: actions/checkout@v7
        with:
          ref: refs/pull/${{ github.event.pull_request.number }}/merge
      - uses: actions/checkout@v7
        with:
          ref: ${{ github.event.pull_request.head.sha }}
      - uses: actions/checkout@v7
        with:
          repository: ${{ github.event.pull_request.head.repo.full_name }}
```

> **We did not run this one**
>
> We read this behaviour from GitHub’s changelog and the release notes. Our run did not trigger a pull\_request\_target workflow from a fork, so we have no log of the refusal to show. The input is documented as “Required to check out fork pull request code from a workflow triggered by pull\_request\_target or workflow\_run”, and GitHub tells you to set it only after reading its guidance on those events.

Two limits are GitHub’s own. The change does not block a checkout of some other untrusted repository set in `repository`, and it does not cover events such as `issue_comment`. The workflow still has to be written carefully. Our [security hardening post](https://www.runners.io/blog/github-actions-security-hardening) covers the rest of the list.

There is a second, separate change. GitHub’s changelog of 2 November 2026 says that from 2 December 2026 Actions will block `pull_request_target` events by default in all public repositories, unless an applicable Actions event policy explicitly allows them. Private and internal repositories are not affected. That is a platform rule and not an input of this action; the changelog says to allow the trigger through an Actions event policy.

## Pin to a tag, or to a SHA?

The 20 July change is the clearest example of what a floating tag does: the same line, `actions/checkout@v4`, ran different code before 20 July 2026 and after it. GitHub’s security guidance lists pinning to a full-length commit SHA as a measure for a repository that cannot adopt a workflow dependency lockfile, and says to pin to a tag only if you trust its creator, because a tag can be moved or deleted if someone gains access to the action’s repository. A SHA does not move. It also does not get fixes unless something moves it: Dependabot, or whoever owns the file.

```yaml
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
```

That SHA is the commit `v7.0.1` points at on the date this post was last checked; check it against the releases page before you copy it, because a copy of a SHA from a web page is the thing the advice is about.

## What we ran, and what we did not

The workflow, the script that reads each checkout back and the rows are in a public repository, in [studies/A1-checkout-reference](https://github.com/runners-io/ci-measurements/tree/main/studies/A1-checkout-reference). Each major version ran nine cases against actions/checkout itself, on a GitHub-hosted `ubuntu-24.04` runner (git 2.56.1), on 17 November 2026; this is [the run](https://github.com/runners-io/ci-measurements/actions/runs/44064719701). We ran one repository, once per version. We did not run SSH keys, LFS, submodules or a second private repository in this reference, and the table’s descriptions of those inputs are GitHub’s own text. We did not run the fork refusal. A statement above that says “in our run” is from these rows, and nothing else is.

If you are looking at the cost of a checkout and not its settings, the [timing post](https://www.runners.io/blog/how-long-does-actions-checkout-take) has it, and [the guide to making GitHub Actions faster](https://www.runners.io/blog/how-to-make-github-actions-faster) puts checkout in order among the other levers. To check a workflow of your own for a deep checkout and a missing timeout, paste it into the [workflow checker](https://www.runners.io/tools/workflow-check). We also keep a [checkout cache](https://www.runners.io/docs/caching/git-checkout-cache) for jobs on our runners; it is documented there, and this reference is about GitHub’s action. Build times measured on GitHub’s runner and on ours are on our [faster GitHub Actions runners, measured](https://www.runners.io/faster-github-actions) page.

## Sources

- [actions/checkout (README)](https://github.com/actions/checkout)
- [actions/checkout action.yml at v7.0.1](https://github.com/actions/checkout/blob/v7.0.1/action.yml)
- [actions/checkout git-source-provider.ts at v7.0.1](https://github.com/actions/checkout/blob/v7.0.1/src/git-source-provider.ts)
- [actions/checkout releases](https://github.com/actions/checkout/releases)
- [actions/checkout tags](https://github.com/actions/checkout/tags)
- [actions/checkout changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Safer pull\_request\_target defaults for GitHub Actions checkout (GitHub changelog, 18 June 2026)](https://github.blog/changelog/2026-06-18-safer-pull_request_target-defaults-for-github-actions-checkout/)
- [Events that trigger workflows](https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows)
- [Secure use reference](https://docs.github.com/en/actions/reference/security/secure-use)
- [pull\_request\_target blocked by default December 2 (GitHub changelog, 2 November 2026)](https://github.blog/changelog/2026-11-02-pull_request_target-blocked-by-default-december-2)
- [ci-measurements, study A1: actions/checkout inputs on v4 to v7](https://github.com/runners-io/ci-measurements/tree/main/studies/A1-checkout-reference)

## Frequently asked questions

### What is the latest version of actions/checkout?

v7.0.1, released on 20 July 2026, which runs on Node 24. The floating tags @v4, @v5 and @v6 also moved on 20 July, to v4.4.0, v5.1.0 and v6.1.0, so each now refuses fork pull request code under pull\_request\_target.

### What is the default fetch-depth in actions/checkout?

1: a single commit, for the ref or SHA that triggered the workflow. fetch-depth: 0 fetches all history for all branches and tags. In our run the default left 1 commit and no tags, and 0 left 234 commits and 68 tags.

### Should I set persist-credentials to false?

Yes, in any job that does not push or fetch after the checkout. By default the token stays configured for later git commands: in .git/config on v4 and v5, and in a file under the runner's temp directory on v6 and v7.

### Why did actions/checkout start failing on pull\_request\_target?

Since 20 July 2026 every current major refuses to check out a fork pull request's code in pull\_request\_target and workflow\_run workflows. Review GitHub's guidance, then set allow-unsafe-pr-checkout: true only if the job must run the fork's code.
