Skip to content

git_pr creates, lists, and merges pull requests / merge requests on the detected forge provider (GitHub, GitLab, Forgejo, Gitea, Bitbucket). It uses the provider CLI (gh/glab/tea) when installed locally, otherwise the provider REST API with a *_TOKEN env var.

Provider detection

The provider is detected from the origin remote URL:

HostProviderCLIToken
github.comGitHubghGITHUB_TOKEN
gitlab.comGitLabglabGITLAB_TOKEN
codeberg.orgForgejoteaFORGEJO_TOKEN
gitea.comGiteateaFORGEJO_TOKEN
bitbucket.orgBitbucketBITBUCKET_TOKEN

For self-hosted instances that cannot be detected from the hostname, set GIT_FORGE_PROVIDER to github | gitlab | forgejo | gitea | bitbucket.

Tool

git_pr

ParameterTypeDescription
repo_pathstringAbsolute path to the Git repository.
action"create" | "list" | "merge"Pull request operation.
titlestringPR/MR title (create).
bodystringPR/MR body/description (create).
basestringTarget branch (create, default main).
headstringSource branch (create, default HEAD).
state"open" | "closed" | "all"Filter for list (default open).
numbernumberPR/MR number (merge).
method"merge" | "squash" | "rebase"Merge method (merge).
response_format"markdown" | "json"Output format. Defaults to "markdown".

Actions

create

Create a pull request / merge request.

text
git_pr  action=create  title="feat: add analytics"  base=main  head=feature/analytics

list

List pull requests / merge requests.

text
git_pr  action=list  state=open

merge

Merge a pull request / merge request.

text
git_pr  action=merge  number=42  method=squash

Configuration

Env varDescription
GITHUB_TOKENGitHub token (REST fallback).
GITLAB_TOKENGitLab token (REST fallback).
FORGEJO_TOKENForgejo/Gitea token (REST fallback).
BITBUCKET_TOKENBitbucket token (REST fallback).
GIT_FORGE_PROVIDERExplicit provider override for self-hosted instances.

Released under the MIT License.