Skip to content
Latchkey

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 automated

In 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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →