.nh .TH "GT-BRANCH-PROTECT" "1" "Nov 2026" "gitea-cli" "gitea-cli Manual" .SH NAME gt-branch-protect - Protect branches .SH SYNOPSIS \fBgt branch protect ... [flags]\fP .SH 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. .PP 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. .PP gt branch protection list and view show the rules. .SH OPTIONS \fB--allow-push\fP=[] Users, or teams as ORG/TEAM, that may push directly .PP \fB--block-on-rejected-reviews\fP[=false] Block merging while changes are requested .PP \fB--dismiss-stale-approvals\fP[=false] Dismiss approvals when new commits are pushed .PP \fB--dry-run\fP[=false] Show the write requests gt would send, without sending them .PP \fB-h\fP, \fB--help\fP[=false] help for protect .PP \fB--pattern\fP="" Protect the branches matching this glob, such as release/* .PP \fB--required-approvals\fP=1 Approving reviews that pull requests need .PP \fB--status-check\fP=[] Status checks that must pass (repeatable) .SH OPTIONS INHERITED FROM PARENT COMMANDS \fB--cwd\fP="" Working \fBdirectory\fR for repository discovery .PP \fB--debug\fP[=false] Log the method, URL, status, and duration of each HTTP request to stderr .PP \fB--host\fP="" Gitea instance \fBURL\fR, including any base path .PP \fB--interactive\fP[=false] Allow prompts with machine output .PP \fB--no-input\fP[=false] Disable prompts and implicit editor/browser interactions .PP \fB--remote\fP="" Git \fBremote\fR used for repository discovery .PP \fB-R\fP, \fB--repo\fP="" Select a repository as \fBOWNER/REPO\fR or URL .PP \fB--sudo\fP="" Perform API requests as this \fBuser\fR (requires an administrator account) .PP \fB--user\fP="" Account \fBname\fR on the selected instance .SH EXAMPLE .EX # 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= .EE .SH SEE ALSO \fBgt-branch(1)\fP