Command referencegh pr close
gh pr close command (Linux & Windows / GitHub CLI)
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 / option | Meaning |
|---|---|
| -c, --comment | Add a closing comment. |
| -d, --delete-branch | Delete 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.
Related commands
- gh pr listList pull requests in a repository with state, author, and search filters.
- gh pr viewDisplay pull request metadata, body, and checks in the terminal or browser.
- gh pr mergeMerge a pull request using merge commit, squash, or rebase strategies.
- gh auth loginAuthenticate the GitHub CLI with GitHub.com or GitHub Enterprise so other gh commands can run.
- gh pr createCreate a pull request from the current branch with title, body, reviewers, and base branch options.
- gitTrack source history and collaborate through distributed repositories.
- gh repo cloneClone a GitHub repository to your machine using your authenticated gh settings.
- gh pr checkoutCheck out a pull request locally as a branch so you can build, test, or review the changes.
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.