GT-PR-CLEAN(1) gitea-cli Manual GT-PR-CLEAN(1)

gt-pr-clean - Delete the branches of a merged or closed pull request

gt pr clean [<number> | <url> | <branch>] [flags]

Delete the local branch of a merged or closed pull request and its head branch on Gitea, switching to the repository's default branch first when the local branch is checked out, and then fast-forwarding that branch.

The local branch is the one at the pull request's head commit, or behind it, that pr checkout created or that has the head branch's name; --ignore-sha selects it by name alone, even with commits that are not in the pull request. A Git remote that pr checkout added for a fork goes with it once no branch tracks it.

The head branch on Gitea is kept when you cannot push to it or another open pull request uses it, and gt refuses to clean when it moved past the pull request. gt never deletes the default branch, the branches of an open pull request, or, without --ignore-sha, a local branch with commits that are not in the pull request. Deleting asks for a confirmation; without a terminal, pass --yes.

gt pr list --local shows which local branches belong to a merged or closed pull request.

A pull request can be supplied as argument in any of the following formats:
- by number, such as "13" or "#13"
- by URL, such as "https://gitea.com/OWNER/REPO/pulls/13"
- by the name of its head branch, such as "feature/login" or "bob:feature/login"; a branch that
  reads as OWNER/REPO#N, such as "fix/login#2", needs the OWNER:BRANCH form
Without an argument, the pull request of the current branch is selected.

default_branch, local_branch, remote, remote_branch, remote_deleted,
remote_skip_reason, remote_skipped, removed_remote

-h, --help[=false] help for clean

--ignore-sha[=false] Find the local branch by name instead of commit hash

--csv[=""] Output CSV with the specified comma-separated fields, or all fields

--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

-q, --jq="" Filter JSON output using a jq expression; implies --json

--json[=""] Output JSON with the specified comma-separated fields, or all fields

--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

-y, --yes[=false] Accept confirmations without prompting

# After #13 was merged, delete its branch locally and on Gitea
$ gt pr clean 13

gt-pr(1)

Nov 2026 gitea-cli