>_ ghcli.com
ghcli / Pull Requests / gh pr create

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.

Quick answer
gh pr create --fill

Syntax

gh pr create [flags]

Examples

Interactive — gh asks for title, body, base, and reviewers

gh pr create

Auto-fill title and body from your commits

gh pr create --fill

Set everything up front

gh pr create --title "Add rate limiting" --body "Closes #42" --base main

Open a draft PR for early feedback

gh pr create --draft --fill

Request reviewers and add labels

gh pr create --fill --reviewer alice,bob --label backend

Skip the prompts and finish it in the browser

gh pr create --web

Options & flags

FlagWhat it does
--fillUse commit info for the title and body (great for scripts).
--fill-firstUse only the first commit for the title and body.
-t, --titleSet the pull request title.
-b, --bodySet the pull request body. Use --body-file - to read from stdin.
-B, --baseThe branch you want to merge into (defaults to the repo default branch).
-H, --headThe branch that contains your changes (defaults to the current branch).
-d, --draftOpen the pull request as a draft.
-r, --reviewerRequest reviews from users or teams (comma-separated).
-a, --assigneeAssign people to the PR. Use @me for yourself.
-l, --labelAdd labels by name.
-w, --webContinue creating the pull request on github.com.

How to use gh pr create, step by step

  1. Commit your work on a feature branch and push it: git push -u origin my-branch.
  2. From inside the repository, run gh pr create.
  3. Pick the base branch when prompted (usually main), or pass --base main.
  4. Give it a title and body, or pass --fill to reuse your commit messages.
  5. 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.