---
name: "gt-branch-protect"
section: "1"
platform: "linux"
package: "gitea-cli"
version: "1.0.0-1"
release: "Arch Linux 2026-11-07"
platforms: ["linux"]
url: "https://carta.tech/man/gt-branch-protect"
---

# gt-branch-protect(1)

Protect branches

## NAME

gt-branch-protect - Protect branches

## SYNOPSIS

**gt branch protect \<branch\>... \[flags\]**

## DESCRIPTION

Add a protection rule for each existing branch, or with --pattern for every branch matching a glob. By default nobody can push directly and pull requests need one approving review.

When a branch or pattern has a rule already, change only the settings the flags name and keep the others; --allow-push replaces those who may push directly. An empty --allow-push= lets nobody push directly again, and an empty --status-check= stops requiring status checks.

## OPTIONS

**--allow-push**=\[\]\
 	Users, or teams as ORG/TEAM, that may push directly

**--block-on-rejected-reviews**\[=false\]\
 	Block merging while changes are requested

**--dismiss-stale-approvals**\[=false\]\
 	Dismiss approvals when new commits are pushed

**-h**, **--help**\[=false\]\
 	help for protect

**--pattern**=""\
 	Protect the branches matching this glob, such as release/\*

**--required-approvals**=1\
 	Approving reviews that pull requests need

**--status-check**=\[\]\
 	Status checks that must pass (repeatable)

## OPTIONS INHERITED FROM PARENT COMMANDS

**--cwd**=""\
 	Working **directory** for repository discovery

**--debug**\[=false\]\
 	Log the method, URL, status, and duration of each HTTP request to stderr

**--host**=""\
 	Gitea instance **URL**, including any base path

**--interactive**\[=false\]\
 	Allow prompts with machine output

**--no-input**\[=false\]\
 	Disable prompts and implicit editor/browser interactions

**--remote**=""\
 	Git **remote** used for repository discovery

**-R**, **--repo**=""\
 	Select a repository as **OWNER/REPO** or URL

**--sudo**=""\
 	Perform API requests as this **user** (requires an administrator account)

**--user**=""\
 	Account **name** on the selected instance

## EXAMPLE

```
# Require two approvals and passing CI on main
$ gt branch protect main --required-approvals 2 --status-check ci/build
# Let the release team push to every release branch
$ gt branch protect --pattern 'release/*' --allow-push acme/release
# Stop requiring status checks on main
$ gt branch protect main --status-check=
```

## SEE ALSO

**[gt-branch(1)](/man/gt-branch/1.md)**
