BarkleyGitHub
Controls · BR
Markdown file

Branch and tag protection

Only people with write access can push to your repository. These rules stop a mistake, a rushed push or someone with a leaked token from changing what users install.

From the 2026 sweepOf the 909 apps that run a security check, 537 protect their main branch, and across the whole Marketplace, 85 apps released a tag whose commit isn't on main at all. The Marketplace report has more on this.

Why this matters

Your checks only protect users if code can't reach them any other way. Branch rules make main that place. Nothing lands there without passing the checks, and nobody can rewrite what's already there.

That only helps if your releases come from main too. A tag can point at any commit, including one on a side branch that never ran your checks, and a release built from it skips all of them. Tag rules then keep a published version from being moved to different code later.

Controls

  1. BR-1Level 2Level markerAdd a branch ruleset for main. Settings → Rules → Rulesets → New branch ruleset.

    • Enforcement: Active.
    • Target: the default branch.
    • Turn on Restrict deletions.
    • Turn on Block force pushes.
    • Turn on Require a pull request before merging. Zero required approvals is fine if you work alone, because the pull request still runs your checks before anything lands.
  2. BR-2WithdrawnRequire your checks to pass. Withdrawn on November 27, 2026, because GATE-1 and GATE-2 require the same checks and name them.

  3. BR-3Level 2Keep the bypass list short. If you add yourself so you can merge in an emergency, every bypass is logged. Don't add bots or apps you don't control.

  4. BR-4Level 3 (or immutable releases)Level markerAdd a tag ruleset for your release tags. Settings → Rules → Rulesets → New tag ruleset.

    • Enforcement: Active. A disabled ruleset protects nothing.
    • Target: v*, or however you name versions.
    • Turn on Restrict updates and Restrict deletions, so a published version can't be moved to different code later.
    • Turn on Restrict creations if only you should cut releases. Then add the Repository admin role to the bypass list, or you won't be able to push new tags either.

Check it worked

In a test clone, change the last commit with git commit --amend and try git push --force to main. GitHub should refuse it. Then move an old tag with git tag -f v1.0.0 HEAD and git push --force origin v1.0.0, which GitHub should refuse too. git fetch --tags --force puts your local tag back. If you're on the bypass list, both pushes go through.

Barkley flags a release tag whose commit isn't on the main branch.

Open the full page