gh-pr-comment1
Add a comment to a pull request
Usage
gh pr
comment
[{<number> | <url> | <branch>}]
[flags]
Overview
Add a comment to a GitHub pull request.
Without body text or attachments supplied through flags, the command will interactively prompt for the comment text.
Use --attach to upload an image or video. If the body already references an attached file, such as , that reference is rewritten to point at the uploaded asset. Any attached file the body does not reference is appended to the end of the comment. You can attach up to 50 files per command.
Alt text for an image follows the path after #, as in --attach './login.png#The login error state'. Without it the filename is used. A reference already in the body keeps the alt text written there. Video renders as a player and has no alt text, so it cannot be given any.
Options
-
--attach <file> -
Attach an image or video file, in '#' format
-
-b, --body <text> -
The comment body text
-
-F, --body-file <file> -
Read body text from file (use "-" to read from standard input)
-
--create-if-none -
Create a new comment if no comments are found. Can be used only with --edit-last
-
--delete-last -
Delete the last comment of the current user
-
--edit-last -
Edit the last comment of the current user
-
-e, --editor -
Skip prompts and open the text editor to write the body in
-
-w, --web -
Open the web browser to write the comment
-
--yes -
Skip the delete confirmation prompt when --delete-last is provided
Options inherited from parent commands
-R,--repo<[HOST/]OWNER/REPO>-
Select another repository using the [HOST/]OWNER/REPO format
Exit status
0: Successful execution
1: Error
2: Command canceled
4: Authentication required
NOTE: Specific commands may have additional exit codes. Refer to the command's help for more information.
Examples
# Add a comment to a pull request $ gh pr comment 13 --body "Hi from GitHub CLI" # Attach a screenshot, with alt text after "#" $ gh pr comment 13 --attach './login.png#The login error state' # Attach multiple files by repeating the flag $ gh pr comment 13 --attach ./before.png --attach ./after.png
Releases
3 releases since Debian 12 (Bookworm); the text changed 2 times.
--attach since Arch Linux 2026-11-01;
--create-if-none since Arch Linux 2026-11-01;
--delete-last since Arch Linux 2026-11-01;
--yes since Arch Linux 2026-11-01.