gh-pr-create - Man Page
Create a pull request
Examples (TL;DR)
- Interactively create a pull request:
gh pr create
- Create a pull request, determining the title and description from the commit messages of the current branch:
gh pr create --fill
- Create a draft pull request:
gh pr create --draft
- Create a pull request specifying the base branch, title, and description:
gh pr create --base base_branch --title "title" --body "body"
- Start opening a pull request in the default web browser:
gh pr create --web
Synopsis
gh pr create [flags]
Description
Create a pull request on GitHub.
When the current branch isn't fully pushed to a git remote, a prompt will ask where to push the branch and offer an option to fork the base repository. Use --head to explicitly skip any forking or pushing behavior.
A prompt will also ask for the title and the body of the pull request. Use --title and --body to skip this, or use --fill to autofill these values from git commits. It's important to notice that if the --title and/or --body are also provided alongside --fill, the values specified by --title and/or --body will take precedence and overwrite any autofilled content.
The base branch for the created PR can be specified using the --base flag. If not provided, the value of gh-merge-base git branch config will be used. If not configured, the repository's default branch will be used.
Link an issue to the pull request by referencing the issue in the body of the pull request. If the body text mentions Fixes #123 or Closes #123, the referenced issue will automatically get closed when the pull request gets merged.
By default, users with write access to the base repository can push new commits to the head branch of the pull request. Disable this with --no-maintainer-edit.
Adding a pull request to projects requires authorization with the project scope. To authorize, run gh auth refresh -s project.
Options
- -a, --assignee <login>
Assign people by their login. Use "@me" to self-assign.
- -B, --base <branch>
The branch into which you want your code merged
- -b, --body <string>
Body for the pull request
- -F, --body-file <file>
Read body text from file (use "-" to read from standard input)
- -d, --draft
Mark pull request as a draft
- --dry-run
Print details instead of creating the PR. May still push git changes.
- -e, --editor
Skip prompts and open the text editor to write the title and body in. The first line is the title and the remaining text is the body.
- -f, --fill
Use commit info for title and body
- --fill-first
Use first commit info for title and body
- --fill-verbose
Use commits msg+body for description
- -H, --head <branch>
The branch that contains commits for your pull request (default [current branch])
- -l, --label <name>
Add labels by name
- -m, --milestone <name>
Add the pull request to a milestone by name
- --no-maintainer-edit
Disable maintainer's ability to modify pull request
- -p, --project <title>
Add the pull request to projects by title
- --recover <string>
Recover input from a failed run of create
- -r, --reviewer <handle>
Request reviews from people or teams by their handle
- -T, --template <file>
Template file to use as starting body text
- -t, --title <string>
Title for the pull request
- -w, --web
Open the web browser to create a pull request
Options Inherited from Parent Commands
- -R, --repo <[HOST/]OWNER/REPO>
Select another repository using the [HOST/]OWNER/REPO format
Aliases
gh pr new
Exit Codes
0: Successful execution
1: Error
2: Command canceled
4: Authentication required
NOTE: Specific commands may have additional exit codes. Refer to the command's help for more information.
Example
$ gh pr create --title "The bug is fixed" --body "Everything works again" $ gh pr create --reviewer monalisa,hubot --reviewer myorg/team-name $ gh pr create --project "Roadmap" $ gh pr create --base develop --head monalisa:feature $ gh pr create --template "pull_request_template.md"