gh pr create Command Reference
Open a pull request from the command line, fully non-interactively.
gh pr create opens a pull request for the current branch. With explicit flags it runs without prompts, which is what automation and bot PRs require.
What it does
gh pr create opens a PR from the current (or specified) head branch into a base branch, setting title, body, reviewers, labels, and draft status. Without flags it prompts interactively; in CI you pass everything explicitly.
Common flags and usage
- --title / --body / --body-file: set the PR title and description
- --base BRANCH / --head BRANCH: target and source branches
- --draft: open as a draft PR
- --label / --reviewer / --assignee: apply metadata
- --fill: derive title and body from commits
Example
shell
- name: Open automated PR
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr create --base main --head "${BRANCH}" \
--title "chore: automated dependency bump" \
--body "Opened by CI." --label automatedIn CI
Always pass --title and --body (or --fill) so gh pr create never blocks on a prompt. Set GH_TOKEN from secrets.GITHUB_TOKEN so the call is authenticated.
Key takeaways
- Pass --title and --body (or --fill) so the command never prompts in CI.
- --base and --head control the target and source branches explicitly.
- Set GH_TOKEN so the PR is created as an authenticated actor.
Related guides
gh pr merge Command ReferenceReference for gh pr merge in CI/CD: merge a pull request non-interactively with squash, merge, or rebase stra…
gh pr comment Command ReferenceReference for gh pr comment in CI/CD: post or update a comment on a pull request from a pipeline, ideal for p…
gh workflow run Command ReferenceReference for gh workflow run in CI/CD: trigger a workflow_dispatch run from the CLI, pass inputs, and pick a…