actions/checkout stops with git exit code 128 in a workflow
Fix it fast
Most common cause, 1 of 4Checkout 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.
- name: Checkout private tools
uses: actions/checkout@v7
with:
repository: my-org/my-private-tools
token: ${{ secrets.GH_PAT }}
path: my-toolsShort 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.
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.
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:
- 1Checkout reads another private repository with the default token
Syncing repository names a repository other than the one running the workflow, followed by remote: Repository not found. - 2A permissions block left the token without contents access
The failing checkout is the workflow's own private repository, and the workflow or job declares permissions without listing contents - 3Private submodules cannot be fetched with the workflow token
The main repository fetch succeeds, and the 128 exit appears while checkout updates submodules - 4A pull_request run tries to push from a detached HEAD
Checkout 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 128remote: 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.
grep -n -A4 "uses: actions/checkout" .github/workflows/*.ymlFix
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.
- name: Checkout private tools
uses: actions/checkout@v7
with:
repository: my-org/my-private-tools
token: ${{ secrets.GH_PAT }}
path: my-toolsVerify
The step log shows the fetch completing for my-org/my-private-tools and the next step finds the files under my-tools.
gh run view <new-run-id> --log | grep -n "my-private-tools"Confirmed by raw.githubusercontent.com
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.
grep -n -A6 "permissions:" .github/workflows/*.ymlFix
Add contents: read to the same permissions block, the setting the checkout README recommends. Use contents: write only in jobs that push.
permissions:
contents: read
id-token: writeVerify
The checkout step passes on the next run without any change to secrets.
gh run view <new-run-id> --log | grep -n "Syncing repository"Confirmed by docs.github.com
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.
cat .gitmodulesFix
Pass a token or an SSH key that can read every submodule repository to the checkout step that has submodules enabled.
- 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.
gh run view <new-run-id> --log | grep -n -i "submodule"Confirmed by raw.githubusercontent.com
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.
grep -n -A3 "^on:" .github/workflows/*.ymlFix
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.
- 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 pushVerify
The push step finishes and the generated commit shows up on the pull request.
gh run view <new-run-id> --log | grep -n -A3 "git push"Confirmed by raw.githubusercontent.com
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.