gh pr create
Open a pull request from the command line
gh pr create is the GitHub CLI command that turns your current branch into a pull request without opening a browser. Push your work, run one command, and gh reads the branch, base, title, and body — or prompts you for them — then prints the PR URL.
gh pr create --fillSyntax
gh pr create [flags]Examples
Interactive — gh asks for title, body, base, and reviewers
gh pr createAuto-fill title and body from your commits
gh pr create --fillSet everything up front
gh pr create --title "Add rate limiting" --body "Closes #42" --base mainOpen a draft PR for early feedback
gh pr create --draft --fillRequest reviewers and add labels
gh pr create --fill --reviewer alice,bob --label backendSkip the prompts and finish it in the browser
gh pr create --webOptions & flags
| Flag | What it does |
|---|---|
| --fill | Use commit info for the title and body (great for scripts). |
| --fill-first | Use only the first commit for the title and body. |
| -t, --title | Set the pull request title. |
| -b, --body | Set the pull request body. Use --body-file - to read from stdin. |
| -B, --base | The branch you want to merge into (defaults to the repo default branch). |
| -H, --head | The branch that contains your changes (defaults to the current branch). |
| -d, --draft | Open the pull request as a draft. |
| -r, --reviewer | Request reviews from users or teams (comma-separated). |
| -a, --assignee | Assign people to the PR. Use @me for yourself. |
| -l, --label | Add labels by name. |
| -w, --web | Continue creating the pull request on github.com. |
How to use gh pr create, step by step
- Commit your work on a feature branch and push it:
git push -u origin my-branch. - From inside the repository, run
gh pr create. - Pick the base branch when prompted (usually
main), or pass--base main. - Give it a title and body, or pass
--fillto reuse your commit messages. - gh prints the new pull request URL — open it with
gh pr view --web.
Common errors and fixes
must be on a branch named differently than "main"
You are on the default branch. Create and switch to a feature branch first: git switch -c my-feature, commit, push, then run the command again.
pull request create failed: GraphQL: No commits between main and my-branch
Your branch has no new commits compared to the base, so there is nothing to merge. Commit something and push before creating the PR.
aborted: you must first push the current branch to a remote
gh needs the branch on GitHub. Push it with git push -u origin HEAD, or let gh push for you when it asks.
Related commands
Frequently asked questions
How do I create a pull request with GitHub CLI?
Push your branch, then run gh pr create inside the repository. Add --fill to auto-populate the title and body from your commits, or answer the interactive prompts.
What does gh pr create --fill do?
--fill skips the title and body prompts by reusing your commit messages: the first commit becomes the title and the rest become the body. It is the fastest way to open a PR and is ideal inside scripts.
Can I open a draft pull request from the terminal?
Yes. Add the --draft flag: gh pr create --draft --fill. Draft PRs cannot be merged until you mark them ready with gh pr ready.
How do I set the base branch for the PR?
Pass --base, for example gh pr create --base develop. Without it, gh targets the repository's default branch.