GitHub CLI Cheatsheet

Issues

Use this GitHub CLI reference while you build software engineering projects, review code, or refresh the syntax you reach for most.

Creating

gh issue create                        # prompts for title and body
gh issue create -t "crash on empty input" -b "steps: run with no args"
gh issue create --title "docs: fix typo" --body-file ./report.md
gh issue create --body-file - < report.md
gh issue create --assignee @me --label bug --label p1
gh issue create --milestone "v2.1" --project Roadmap
gh issue create --template bug_report.md
gh issue create --type Bug
gh issue create --editor                # $EDITOR, first line is the title
gh issue create --web                   # open the new-issue form
gh issue create -R cli/cli -t "..." -b "..."
FlagEffect
-t, --title, -b, --bodySet inline, otherwise prompted
-F, --body-fileBody from a file, - for stdin
-T, --template <name>Start from an issue template by name
-a, --assigneeLogins, @me for yourself
-l, --label, -m, --milestone, -p, --projectMetadata by name or title
--type <name>Issue type, where the org has them configured
--parent <number>File it as a sub-issue of that issue
--blocking, --blocked-byDependency links to other issue numbers
-e, --editorCompose in $EDITOR
--recover <file>Recover input from a failed create

-R OWNER/REPO works on every gh issue subcommand, so you can file into another repo from anywhere.

Listing and Searching

gh issue list                          # open issues, 30 max
gh issue list --state all --limit 200
gh issue list --assignee @me
gh issue list --author alice --label bug
gh issue list --label bug --label p1    # AND, not OR
gh issue list --milestone "v2.1"
gh issue list --mention @me
gh issue list --app dependabot
gh issue list --json number,title,labels
gh issue list --web
FlagFilter
-s, --stateopen (default), closed, all
-A, --author, -a, --assigneeLogins or @me
-l, --labelRepeatable, all must match
-m, --milestoneNumber or title
--mentionIssues mentioning a login
--typeIssue type name
-S, --searchFull GitHub search syntax
-L, --limitMax results

Search Query Syntax

The flags cover the common cases. --search covers everything else, using the same qualifiers as the web search box.

gh issue list --search "is:open no:assignee label:bug"
gh issue list --search "sort:comments-desc"
gh issue list --search "created:2026-01-01..2026-03-31"
gh issue list --search "updated:<2025-01-01 is:open"   # stale issues
gh issue list --search "in:title parser"
gh issue list --search "-label:wip -label:blocked"
gh issue list --search "involves:@me is:open"
gh issue list --search "comments:>20 reactions:>10"
gh issue list --search "linked:pr"
gh issue list --search "state:open type:Bug"
gh search issues "memory leak" --owner cli --limit 50
QualifierMatches
is:open, is:closed, is:lockedState
no:assignee, no:label, no:milestoneMissing metadata
author:, assignee:, mentions:, involves:, commenter:People, @me allowed
label:, milestone:, project:Metadata, prefix with - to negate
created:, updated:, closed:Dates, with >, <, >=, or A..B
comments:, reactions:, interactions:Counts, with comparisons
in:title, in:body, in:commentsWhere the free text must appear
linked:pr, linked:issueCross references
sort:created-desc, sort:updated-asc, sort:comments-descOrdering

Repeating a flag means AND. To express OR, drop into --search or run two queries.

Viewing and Commenting

gh issue view 42
gh issue view 42 --comments
gh issue view https://github.com/cli/cli/issues/42
gh issue view 42 --web
gh issue view 42 --json title,body,labels,assignees
gh issue view 42 --json comments --jq '.comments[-1].body'
gh issue comment 42 --body "reproduced on 2.95.0"
gh issue comment 42 --body-file notes.md
gh issue comment 42 --editor
gh issue comment 42 --edit-last --body "reproduced, patch incoming"
gh issue comment 42 --edit-last --create-if-none --body "status: green"

--edit-last --create-if-none is the idiom for a bot that keeps one rolling status comment instead of spamming a thread.

Editing and Closing

gh issue edit 42 --title "crash on empty argv"
gh issue edit 42 --body-file ./body.md
gh issue edit 42 --add-label confirmed --remove-label needs-info
gh issue edit 42 --add-assignee alice --remove-assignee @me
gh issue edit 42 --milestone "v2.2"
gh issue edit 42 --remove-milestone
gh issue edit 42 --add-project Roadmap
gh issue edit 42 --parent 40             # make it a sub-issue of 40
gh issue edit 42 --add-sub-issue 51
gh issue edit 42 --add-blocked-by 39
gh issue edit 42 43 44 --add-label triage  # several at once
gh issue close 42
gh issue close 42 --reason completed
gh issue close 42 --reason "not planned"
gh issue close 42 --duplicate-of 40      # closes as a duplicate
gh issue close 42 --comment "fixed in v2.1"
gh issue reopen 42 --comment "still happening"
gh issue delete 42                       # asks for confirmation

--reason takes completed, not planned, or duplicate. Passing --duplicate-of sets the reason for you and links the two issues.

Branches, Transfers, Pins, Locks

gh issue develop creates the linked branch GitHub shows under "Development", so the branch and the issue stay tied together.

gh issue develop 42                      # create a linked branch
gh issue develop 42 --checkout           # create it and switch to it
gh issue develop 42 --name fix/empty-argv --base develop
gh issue develop 42 --branch-repo my-fork
gh issue develop 42 --list               # branches already linked
gh issue transfer 42 other-org/other-repo
gh issue transfer https://github.com/o/r/issues/42 o/target
gh issue pin 42                          # pinned issues show at the top
gh issue unpin 42
gh issue lock 42 --reason too_heated
gh issue unlock 42

Lock reasons are off_topic, resolved, spam, and too_heated. A repo allows at most three pinned issues, so pinning a fourth fails.