Skip to content
Latchkey

ad-m/github-push-action "remote rejected" on a protected branch

Branch protection can require reviews, status checks, or block force pushes. A bot push that violates a rule is rejected by the protected-branch hook regardless of token scope.

What this error means

The push step fails with "[remote rejected]" and "protected branch hook declined".

github-actions
! [remote rejected] HEAD -> main (protected branch hook declined)
error: failed to push some refs to 'https://github.com/owner/repo'

Common causes

Required reviews on the branch

A direct push to a branch requiring PR review is declined.

Required status checks not satisfied

Pushing to a branch that requires passing checks is blocked.

Force push disallowed

Protection forbids force pushes, so a non-fast-forward push is rejected.

How to fix it

Push to a feature branch and open a PR instead

  1. Have the workflow push to a new branch rather than the protected default.
  2. Open a PR from that branch (or use create-pull-request) for the protected target.
  3. Re-run; the push targets an unprotected branch.
.github/workflows/push.yml
- uses: ad-m/github-push-action@master
  with:
    github_token: ${{ secrets.GITHUB_TOKEN }}
    branch: automated/bot-update

How to prevent it

  • Route automated changes through PRs to protected branches, not direct pushes.
  • Add the bot/app to the protection bypass list only when a direct push is truly required.

Frequently asked questions

What causes ""! [remote rejected] (protected branch hook declined)""?
A direct push to a branch requiring PR review is declined.
How do I fix "! [remote rejected] (protected branch hook declined)"?
Push to a feature branch and open a PR instead

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card