Skip to main content

Command referencegh pr close

gh pr close command (Linux & Windows / GitHub CLI)

Linux & WindowsGitHub CLIgitbeginner

What it does

Close a pull request without merging it. When people search for gh pr close, they usually want practical GitHub CLI flags, safe examples, and how this subcommand fits everyday PR and repo workflows on Linux, Windows, and macOS. Syntax, options, and copyable examples are below.

Close a pull request without merging it.

Syntax

gh pr close {<number> | <url> | <branch>} [flags]

Common options

Flag / optionMeaning
-c, --commentAdd a closing comment.
-d, --delete-branchDelete the head branch after closing.

Practical examples

Close PR

gh pr close 123

Closes pull request 123 without merging.

Close with reason

gh pr close 123 --comment "Superseded by #130"

Closes and leaves a pointer to the replacement PR.

Delete branch

gh pr close 123 --delete-branch

Closes the PR and removes the head branch.

Common mistakes

  • Closing when you meant `gh pr merge`.
  • Deleting a branch still needed by another open PR.

FAQ

What does gh pr close do in GitHub CLI?

Close a pull request without merging it.

Does gh pr close work on Windows and Linux?

Yes. The GitHub CLI (`gh`) runs on Linux, Windows, and macOS with the same subcommand syntax after you authenticate with `gh auth login`.

What is a practical gh pr close example?

Try `gh pr close 123` — Closes pull request 123 without merging.

Do I need a token in the command line for gh pr close?

Prefer `gh auth login` so credentials stay in the system keyring or secure storage. Avoid pasting personal access tokens into shell history.

Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.