Home / Alt manpages / gh-issue-edit(1)

  • gh-issue-edit(1)
  • User command
  • linux

Edit GitHub Issues Safely with gh issue edit

You will finish with a repeatable way to change an issue's title, body, labels, assignees, project or milestone from a shell, then check what GitHub stored. The examples use GitHub CLI 2.87.3, installed here as package gh. Allow about ten minutes for a routine edit.

You need an authenticated gh installation, permission to edit the target repository, and an issue number or URL. These commands change remote GitHub data. There is no general undo flag, so record the current values before making a destructive or hard-to-reconstruct change. Nothing in this guide needs sudo.

1. Check the repository and command version

Start with read-only checks. They make it less likely that a local repository context or an old command sends the edit somewhere unexpected:

$ gh --version
gh version 2.87.3 (...)
$ gh issue edit --help
Edit one or more issues within the same repository.

The installed command accepts an issue number or URL. If you are outside a checked-out repository, use -R OWNER/REPO explicitly:

$ gh issue view 123 -R OWNER/REPO --json number,title,body,labels,assignees,milestone,projectItems
{... current issue data ...}

Replace 123 and OWNER/REPO with real values. Treat the output as your recovery record. The placeholder JSON above is not literal output; field ordering and formatting can vary.

Checkpoint

Confirm the issue number, repository, and old values before proceeding.

2. Change only the fields you intend to change

Each edit flag targets one kind of issue data. A command can combine flags, but keeping related changes together makes the resulting audit trail easier to read:

$ gh issue edit 123 -R OWNER/REPO \
    --title "Login fails after session timeout" \
    --body "Describe the observed behaviour, expected behaviour, and reproduction steps here."
$ printf 'exit status: %s\n' "$?"
exit status: 0

--title replaces the title and --body replaces the complete body. They do not append text. Keep the shell quotes around values containing spaces, punctuation or Markdown. A zero exit status means the command completed successfully; verify the stored values in the next step.

For a longer body, put the exact Markdown in a file and use --body-file. This avoids shell quoting errors and makes the proposed replacement reviewable:

$ editor /tmp/issue-123-body.md
$ gh issue edit 123 -R OWNER/REPO --body-file /tmp/issue-123-body.md
$ gh issue view 123 -R OWNER/REPO --json number,title,body

--body-file - reads from standard input, so a reviewed pipeline can also supply the body. Do not pipe untrusted generated text into a remote edit without reading it first.

3. Verify the title and body

Read the fields back from GitHub rather than relying only on the exit status:

$ gh issue view 123 -R OWNER/REPO --json number,title,body
{"body":"Describe the observed behaviour, expected behaviour, and reproduction steps here.","number":123,"title":"Login fails after session timeout"}

The JSON will be escaped and formatted according to your installed gh version. Check that the issue number and title are correct, and that the body is the complete text you meant to publish. If you saved the old body, restore it with --body-file and verify again.

4. Add or remove labels and assignees

Labels and assignees are changed incrementally. The add and remove forms are separate, so inspect the current list before choosing them:

$ gh issue edit 123 -R OWNER/REPO \
    --add-label "bug,help wanted" \
    --remove-label "needs triage" \
    --add-assignee "@me" \
    --remove-assignee "old-handle"
$ gh issue view 123 -R OWNER/REPO --json number,labels,assignees

Label names in the comma-separated value must match labels available in the repository. The special assignee value @me means the authenticated user. The installed help also recognises @copilot, although GitHub Enterprise Server does not support that value according to the command help.

This example removes state from the issue. Before running it, make sure old-handle is the person you mean and that removing needs triage will not hide a workflow signal. Recovery is another edit: add the label or assignee again if you recorded the previous state.

5. Change a milestone or project

Use a milestone name to set or replace the issue's milestone:

$ gh issue edit 123 -R OWNER/REPO --milestone "Version 2"
$ gh issue view 123 -R OWNER/REPO --json number,milestone

To remove the milestone, use the dedicated flag. This is different from passing an empty name:

$ gh issue edit 123 -R OWNER/REPO --remove-milestone
$ gh issue view 123 -R OWNER/REPO --json number,milestone

Projects need extra authorisation. If the command reports a missing scope, refresh the logged-in account with the project scope, then retry after checking the target project name:

$ gh auth refresh -s project
$ gh issue edit 123 -R OWNER/REPO --add-project "Roadmap"
$ gh issue view 123 -R OWNER/REPO --json number,projectItems

Refreshing authorisation can open a browser or prompt for a token, depending on how gh was installed and authenticated. Do not paste a token into a shell history entry. Project edits are remote changes; verify the returned project items and use --remove-project with the exact project title if you need to recover.

6. Edit several issues with care

The command accepts several issue numbers in one invocation when the same change is appropriate for all of them:

$ gh issue edit 123 124 -R OWNER/REPO --add-label "release-note"
$ gh issue view 123 -R OWNER/REPO --json number,labels
$ gh issue view 124 -R OWNER/REPO --json number,labels

Use this only after checking every target. A shared command is efficient, but it also spreads a typo or unsuitable label across the whole set. Prefer separate commands when the bodies, titles or safety consequences differ.

Common failure points

  • A command aimed at the wrong repository is still a valid command. Add -R OWNER/REPO when the repository context is not obvious.
  • --body replaces the body. Use --body-file for a reviewed full replacement, and keep the old content until verification succeeds.
  • An absent label, milestone or project name may be a naming problem rather than an authentication problem. Check the exact name in GitHub before changing credentials.
  • A non-zero status means the edit needs investigation. For attachments, newer upstream documentation describes partial success, but the installed manpage and help for this machine do not expose an attachment flag, so this guide does not use it.

Done means

  • The target repository and issue were confirmed before editing.
  • The old title, body and relevant metadata were recorded when recovery mattered.
  • Only the intended fields were changed with gh issue edit.
  • The result was read back with gh issue view.
  • Any project-scope request was handled through gh auth refresh -s project, without exposing a token.