The main parent projects repo.
gh api -X PUT \
-H "Accept: application/vnd.github+json" \
repos/brad-projects/projects/branches/main/protection \
--input protection.jsonExactly — this error happens because you just enabled branch protection requiring pull requests. Once that rule is active, you cannot push directly to main; all changes must go through a pull request.
Here’s what to do next:
- Create a new branch locally:
git checkout -b protection-policy- Commit your changes to the new branch (you already did, so just make sure the branch has the commit):
git log --onelineYou should see your "Add protection policy" commit on protection-policy.
- Push the branch to GitHub:
git push -u origin protection-policy- Create a pull request:
You can do it via the CLI:
gh pr create --base main --head protection-policy --title "Add protection policy" --body "Add branch protection JSON file"Or via the GitHub web interface.
- Merge the PR once approved — this is now the only way to update
mainbecause of the branch protection rule.
If you want, I can show a shortcut one-liner to push and immediately open a PR using gh so you don’t need multiple commands. Do you want that?