Skip to content

Instantly share code, notes, and snippets.

@shaposhnikoff
Created December 18, 2025 11:08
Show Gist options
  • Select an option

  • Save shaposhnikoff/5ecd25061b8c1262ce5da723a730601a to your computer and use it in GitHub Desktop.

Select an option

Save shaposhnikoff/5ecd25061b8c1262ce5da723a730601a to your computer and use it in GitHub Desktop.
gh add branch protection
gh api repos/username/repo_name/branches/main/protection \
  --method PUT \
  --input - <<'JSON'
{
  "required_status_checks": null,
  "enforce_admins": true,
  "required_pull_request_reviews": {
    "dismiss_stale_reviews": false,
    "require_code_owner_reviews": true,
    "require_last_push_approval": false,
    "required_approving_review_count": 1
  },
  "restrictions": null,
  "required_linear_history": false,
  "allow_force_pushes": false,
  "allow_deletions": false,
  "block_creations": false,
  "required_conversation_resolution": false,
  "lock_branch": true,
  "allow_fork_syncing": false
}
JSON

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment