semantic-release "@semantic-release/git" step failed in CI
The @semantic-release/git plugin commits release assets (CHANGELOG, package.json) and pushes them back to the branch. It fails when the push is rejected: no write permission, a protected branch, or the branch moved ahead during the run.
What this error means
The run fails at "Failed step \"prepare\" of plugin \"@semantic-release/git\"" or a git push error while committing release files.
semantic-release
[semantic-release] > Failed step "prepare" of plugin "@semantic-release/git"
error: failed to push some refs to 'https://github.com/owner/repo.git'
hint: Updates were rejected because the remote contains work that you do not have locally.Common causes
The token cannot push the release commit
Missing contents write, a protected branch, or read-only credentials block the commit-and-push the git plugin performs.
The branch advanced during the run
Another push landed between analysis and the git plugin push, so the non-fast-forward push is rejected.
How to fix it
Ensure push permission and a bypass token
- Grant
contents: writeand use a token that can push (App/PAT if protected). - Set fetch-depth: 0 and persist credentials so the push authenticates.
- Add a concurrency group so runs do not race the branch.
.github/workflows/release.yml
permissions:
contents: write
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: falseLimit what the git plugin commits
Commit only the assets you intend so the push is minimal and predictable.
.releaserc plugins
["@semantic-release/git", {
"assets": ["CHANGELOG.md", "package.json"],
"message": "chore(release): ${nextRelease.version} [skip ci]"
}]How to prevent it
- Give the release job push permission and a bypass-capable token.
- Use a concurrency group so the branch does not move mid-run.
- Include [skip ci] in the release commit message to avoid loops.
Related guides
semantic-release push to protected branch rejected in CIFix semantic-release push rejected by a protected branch rule in CI - the default GITHUB_TOKEN cannot bypass…
semantic-release "EGITNOPERMISSION" cannot push to the repository in CIFix semantic-release "EGITNOPERMISSION The push permission to the Git repository is required" in CI - the tok…
semantic-release "Cannot find module '@semantic-release/...'" plugin in CIFix semantic-release "Cannot find module '@semantic-release/git'" (or similar) in CI - a plugin listed in con…