Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Servers, nginx and Docker

actions/checkout stops with git exit code 128 in a workflow

Your error

Error: The process '/usr/bin/git' failed with exit code 1282 more lines it can show

Fix it fast

Most common cause, 1 of 4

Checkout reads another private repository with the default token

Store a token that can read the other repository as a secret and pass it to that checkout step.

Fix
- name: Checkout private tools
  uses: actions/checkout@v7
  with:
    repository: my-org/my-private-tools
    token: ${{ secrets.GH_PAT }}
    path: my-tools
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

The process '/usr/bin/git' failed with exit code 128 means a git command inside actions/checkout or a later push step was refused. The default GITHUB_TOKEN only reads the workflow's own repository, and only when contents: read is granted. Pass a PAT or deploy key for other private repos and submodules, add contents: read, or check out the PR branch before pushing.

  • Applies to actions/checkout v7.0, GitHub-hosted runners (ubuntu-latest), GitHub CLI 2.105
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Pull only the failed steps from the run log and look at what git was doing when it died. The Syncing repository line names the repository checkout tried to read. A failure during the submodule update, or in a push step, points to the later causes.

Run this first
gh run view <run-id> --log-failed | grep -nE "Syncing repository|Repository not found|submodule|exit code 128"

Then find the line you see in this list and open its fix:

  1. 1Checkout reads another private repository with the default tokenSyncing repository names a repository other than the one running the workflow, followed by remote: Repository not found.
  2. 2A permissions block left the token without contents accessThe failing checkout is the workflow's own private repository, and the workflow or job declares permissions without listing contents
  3. 3Private submodules cannot be fetched with the workflow tokenThe main repository fetch succeeds, and the 128 exit appears while checkout updates submodules
  4. 4A pull_request run tries to push from a detached HEADCheckout passes, the workflow is triggered by pull_request, and the 128 exit comes from the step that commits and pushes

What does the error look like?

  • Error: The process '/usr/bin/git' failed with exit code 128
  • remote: Repository not found.
  • Error: fatal: repository 'https://github.com/my-org/my-private-tools/' not found

Cause 1 of 4

Checkout reads another private repository with the default token

You seeSyncing repository names a repository other than the one running the workflow, followed by remote: Repository not found.

Check

Exit code 128 with Repository not found, while checkout has a repository: input, means the token cannot see that second repository. The actions/checkout README notes that github.token is limited to the repository that runs the workflow.

Check
grep -n -A4 "uses: actions/checkout" .github/workflows/*.yml

Fix

Store a token that can read the other repository as a secret and pass it to that checkout step. A fine-grained PAT or GitHub App token with read access to contents works; an ssh-key input holding a deploy key is the other option.

Fix
- name: Checkout private tools
  uses: actions/checkout@v7
  with:
    repository: my-org/my-private-tools
    token: ${{ secrets.GH_PAT }}
    path: my-tools

Verify

The step log shows the fetch completing for my-org/my-private-tools and the next step finds the files under my-tools.

Verify
gh run view <new-run-id> --log | grep -n "my-private-tools"

Confirmed by raw.githubusercontent.com

Did this fix it?

Cause 2 of 4

A permissions block left the token without contents access

You seeThe failing checkout is the workflow's own private repository, and the workflow or job declares permissions without listing contents

Check

Declaring any permission for GITHUB_TOKEN switches every permission you did not name to none. A block that grants only id-token: write or pull-requests: write therefore takes away read access to the code, and checkout of a private repository fails with exit code 128.

Check
grep -n -A6 "permissions:" .github/workflows/*.yml

Fix

Add contents: read to the same permissions block, the setting the checkout README recommends. Use contents: write only in jobs that push.

Fix
permissions:
  contents: read
  id-token: write

Verify

The checkout step passes on the next run without any change to secrets.

Verify
gh run view <new-run-id> --log | grep -n "Syncing repository"

Confirmed by docs.github.com

Did this fix it?

Cause 3 of 4

Private submodules cannot be fetched with the workflow token

You seeThe main repository fetch succeeds, and the 128 exit appears while checkout updates submodules

Check

With submodules: true or recursive, checkout pulls each submodule using the token or SSH key handed to that step. The default token is limited to the repository running the workflow, so a private submodule stored in another repository is refused. Without an ssh-key input, git@github.com: submodule URLs are rewritten to HTTPS and go through that token as well.

Check
cat .gitmodules

Fix

Pass a token or an SSH key that can read every submodule repository to the checkout step that has submodules enabled.

Fix
- uses: actions/checkout@v7
  with:
    submodules: recursive
    ssh-key: ${{ secrets.SUBMODULES_DEPLOY_KEY }}

Verify

The checkout log on the next run lists every submodule path without an error, and later steps find their files.

Verify
gh run view <new-run-id> --log | grep -n -i "submodule"

Confirmed by raw.githubusercontent.com

Did this fix it?

Cause 4 of 4

A pull_request run tries to push from a detached HEAD

You seeCheckout passes, the workflow is triggered by pull_request, and the 128 exit comes from the step that commits and pushes

Check

For pull_request events checkout leaves the job on a detached HEAD rather than on your branch, so a later git push has no branch to update. The checkout README says the ref input is required for this case.

Check
grep -n -A3 "^on:" .github/workflows/*.yml

Fix

Check out the head branch of the pull request, set a commit identity, then commit and push. The job also needs contents: write. Runs for pull requests from forks get read-only tokens unless an admin turns on sending write tokens to such workflows.

Fix
- uses: actions/checkout@v7
  with:
    ref: ${{ github.head_ref }}
- run: |
    git config user.name "github-actions[bot]"
    git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
    git add .
    git commit -m "generated"
    git push

Verify

The push step finishes and the generated commit shows up on the pull request.

Verify
gh run view <new-run-id> --log | grep -n -A3 "git push"

Confirmed by raw.githubusercontent.com

Did this fix it?

How do I stop it coming back?

  • Put a permissions block with contents: read at the top of every workflow and widen it per job, so a new job cannot drop code access by accident.
  • Keep cross-repository tokens in one named secret per purpose and record their expiry date next to the secret's name in the repository docs.
  • Pin actions/checkout to a major version and read its release notes when you bump it, since auth handling changed between versions.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.