You can pinpoint the cause from the message shown when git push is rejected.
Quick lookup by error type
| Error message | Cause |
|---|---|
Updates were rejected because the remote contains work | The remote has commits that your local branch does not |
Updates were rejected because the tip of your current branch is behind | Your local branch is behind the remote |
remote: error: GH006: Protected branch update failed | GitHub protected branch |
remote rejected ... pre-receive hook declined | Server hook or protection rule |
Cause 1 — non-fast-forward (most common)
Your push conflicts because someone else has already pushed commits to the remote.
# Check remote state
git fetch origin
git log --oneline HEAD..origin/main # Commits that exist only on the remote
git log --oneline origin/main..HEAD # Commits that exist only in your local repoMethod A: rebase (recommended — keeps commit history clean)
git fetch origin
git rebase origin/main
# If there are no conflicts, you can push immediately
git push origin mainIf a conflict occurs:
# After fixing conflicted files
git add conflicted-file
git rebase --continue
# Abort and roll back
git rebase --abortMethod B: merge
git fetch origin
git merge origin/main
git push origin mainMethod C: pull --rebase (all in one)
git pull --rebase origin main
git push origin mainCause 2 — GitHub Protected Branch
# Example error
# remote: error: GH006: Protected branch update failed
# remote: error: Required status check "CI" is failing.Direct pushes are blocked. How to resolve:
- Merge via Pull Request (the proper way)
- Disable protection in GitHub settings (admin access required)
- Repository → Settings → Branches → Branch protection rules
Bypassing with a force push risks wiping other people's commits in a team workflow. Use a PR instead.
Cause 3 — Remote branch name does not match the current branch
# Check the current branch
git branch
# List remote branches
git branch -r
# Push with an explicit branch mapping
git push origin local-branch:remote-branch
# Example: feature/login → feature/login on origin
git push origin feature/loginCause 4 — The remote repository is not bare
On a self-hosted git server, push is rejected if the remote branch is currently checked out.
# Run on the remote server
git config --bool receive.denyCurrentBranch false
# Or set receive.denyCurrentBranch to updateInstead
git config receive.denyCurrentBranch updateInsteadCause 5 — A large file is included
# Example error
# remote: error: File bigfile.zip is 120.00 MB; this exceeds GitHub's file size limit of 100.00 MB
# Remove the file from that commit
git log --oneline -5
git show --stat HEAD | grep large-file
# Remove only the file from the last commit
git rm --cached large-file.zip
echo "large-file.zip" >> .gitignore
git commit --amend --no-editFor large files, use Git LFS:
git lfs install
git lfs track "*.zip"
git add .gitattributesSummary
| Situation | Fix |
|---|---|
| New commits on the remote | git pull --rebase then push |
| Protected branch | Create a PR |
| Branch name mismatch | Explicitly git push origin local:remote |
| Large file | git rm --cached then amend |
When rejected with protected branch / hook declined
! [remote rejected] ... (protected branch hook declined) means the remote repository (GitHub, etc.) branch protection rules blocked a direct push. Unlike non-fast-forward, this is not fixed by git pull --rebase.
- No direct push to main/master rule → create a new branch and merge via Pull Request.
- Required reviews or status checks not met → merge after review approval and CI passing.
- In an emergency, a repo admin can temporarily adjust the protection rules under Settings → Branches (not recommended).
AI tools may assist drafting. Check the evidence in each guide for whether commands were run and which environment was used. Confirm the current docs for your version before applying instructions, and email us about errors. email us
Questions & answers
Ask a question about this guide. We'll review and reply.