A highly opinionated CLI for creating GitHub pull requests with a consistent structure and automatic related PR tracking.
- detects or prompts for a ticket/tag
- suggests or prompts for a base branch
- opens one editor buffer seeded from a PR template
- creates the PR through
gh - updates the "Related PRs" section across matching PRs
The authoring flow is intentionally simple: no form fields, no placeholder prompts, one editable PR body.
git clone https://github.com/IAmRadek/git-pr.git
cd git-pr
cargo install --path .ghinstalled and authenticated, for GitHub repositoriesglabinstalled and authenticated, for GitLab repositories- a git repository with at least one commit on the current branch
Default config path:
~/.config/git-pr/config.yaml
You can override the config directory with --config or GIT_PR_CONFIG.
Generate a default config:
git-pr --initIf the config file exists, --init does not change it. It prints the default config, with a comment for each option. To save it, run git-pr --init > config.sample.yaml.
Example:
jira:
url: "https://yourcompany.atlassian.net/browse/"
github:
user: "your-username"
template:
path: "/absolute/path/to/pull_request_template.md"
body: |
Related PRs:
<!-- RELATED_PR -->
<!-- /RELATED_PR -->
## Summary
## Changes
## Testing
markers:
related_pr_start: "<!-- RELATED_PR -->"
related_pr_end: "<!-- /RELATED_PR -->"git-pr chooses the forge from the host of the origin remote. github.com and gitlab.com need no entry. For another host, add it under forges:
forges:
git.example.com: github
gitlab.example.com: gitlabIf the host has no forge, git-pr stops with an error.
The GitLab forge uses glab. It assigns the merge request to you, uses .gitlab/merge_request_templates/Default.md as the template, and refers to related merge requests as group/project!12.
The plugins section lists the plugins of each kind, in run order. These are the built-in defaults:
plugins:
ticket_sources: [commit_tags] # the first detected ticket wins
draft_hooks: [template_body] # run before and after the editor
after_create: [related_prs] # run after the PR stepIf a list is missing, git-pr uses its defaults. An empty list turns that kind off. If a name is unknown, git-pr prints a warning and skips it.
The jira ticket source suggests tickets at the PR Tag: prompt. It runs the query in jira.jql and detects nothing. If its jira section or a token variable is wrong, git-pr prints a warning and skips it.
jira:
url: "https://yourcompany.atlassian.net/browse/" # the API address is the part before browse/
kind: cloud # or datacenter
jql: "assignee = currentUser() AND statusCategory != Done ORDER BY updated DESC"
plugins:
ticket_sources: [commit_tags, jira]The token comes from the environment. Jira Cloud needs JIRA_USER (the account email) and JIRA_TOKEN (an API token). Data Center needs JIRA_TOKEN (a personal access token).
The initial PR body is resolved in this order:
.github/PULL_REQUEST_TEMPLATE.mdin the current repositorytemplate.pathfrom configtemplate.bodyfrom config
Before the resolved template content, git-pr prepends ticket context, for example:
Ticket: TRACK-123
Jira: https://yourcompany.atlassian.net/browse/TRACK-123
If the resolved template does not already contain the related-PR marker block, git-pr also prepends:
<!-- RELATED_PR -->
<!-- /RELATED_PR -->
That prepended block is only a convenience. You can move or copy it anywhere in the template once the editor opens.
Create a PR:
git-prThe flow is:
- detect or select the ticket
- select the base branch
- edit the full PR body in your editor
- optionally select reviewers
Update related PRs only:
git-pr --update-onlyDry run:
git-pr --dry-runRelated PR updates only touch the configured marker section:
<!-- RELATED_PR -->
<!-- /RELATED_PR -->
If those markers exist in the PR body, git-pr rewrites that block with links to matching PRs. The rest of the body is left as authored.
src/
├── app.rs
├── cli.rs
├── config.rs
├── error.rs
├── git.rs
├── github.rs
├── jira.rs
├── lib.rs
├── main.rs
├── pr.rs
├── tags.rs
├── template.rs
└── ui.rs
MIT License. See LICENSE.