LinuxCommandLibrary

gh-issue-create

Create new GitHub issues

TLDR

Create a new issue against the current repository interactively

$ gh issue create
copy

Create a new issue with the bug label interactively
$ gh issue create [[-l|--label]] "[bug]"
copy

Create a new issue interactively and assign it to the specified users
$ gh issue create [[-a|--assignee]] [user1,user2,...]
copy

Create a new issue with a title, body and assign it to the current user
$ gh issue create [[-t|--title]] "[title]" [[-b|--body]] "[body]" [[-a|--assignee]] "[@me]"
copy

Create a new issue interactively, reading the body text from a file
$ gh issue create [[-F|--body-file]] [path/to/file]
copy

Create a new issue in the default web browser
$ gh issue create [[-w|--web]]
copy

Display help
$ gh issue create --help
copy

SYNOPSIS

gh issue create [flags]
or
gh issue create --title <string> --body <string> [flags]

PARAMETERS

--assignee <logins>
    Assign people to the issue by their GitHub login.

--body <string>, -b <string>
    Supply the issue's main body content.

--body-file <file>
    Read the issue body text from a specified file (use '-' for stdin).

--editor-body
    Forces opening a text editor for the issue body, even if content is provided by other flags.

--label <strings>, -l <strings>
    Attach labels to the issue by name (can be specified multiple times).

--milestone <name>, -m <name>
    Add the issue to a milestone by its name.

--no-editor
    Skip opening an editor for the issue body, even in interactive mode.

--project <name>, -p <name>
    Add the issue to a project by its name.

--repo <[HOST/]OWNER/REPO>, -R <[HOST/]OWNER/REPO>
    Select another repository to create the issue in (global gh flag).

--template <file>
    Use a markdown file as a template to pre-populate the issue body.

--title <string>, -t <string>
    Provide a title for the new issue.

--web, -w
    Open the issue creation form in the default web browser instead of the terminal.

DESCRIPTION

The gh issue create command is a core feature of the GitHub CLI, empowering developers to create new issues on GitHub repositories directly from their command line interface. This command supports both an interactive mode, which guides the user through prompts for details like title and body, and a non-interactive mode that accepts issue details via command-line flags. The non-interactive mode is ideal for scripting and automation.

Users can specify various attributes for the new issue, including its title, body content, associated labels, assigned users, relevant projects, and milestones. Additionally, it supports applying predefined issue templates to standardize content. By integrating issue creation into the terminal workflow, gh issue create significantly streamlines the process for individual developers and teams, enhancing productivity and maintaining context within the development environment. Upon successful creation, it provides the URL of the new issue.

CAVEATS

The gh issue create command requires the GitHub CLI (gh) to be installed and authenticated to a GitHub account with appropriate permissions to create issues in the target repository. Network connectivity is also necessary for communication with GitHub's API. If neither --title nor --body flags are provided, the command will default to an interactive mode, prompting the user for input.

INTERACTIVE MODE

When gh issue create is executed without specifying a title or body via flags, it defaults to an interactive mode. In this mode, the command prompts the user step-by-step for the issue's title, body, and then offers interactive choices for labels, assignees, projects, and milestones, making it user-friendly for manual issue creation.

USING TEMPLATES

The --template flag is a powerful feature for standardizing issue content. By pointing to a Markdown file containing a predefined structure or boilerplate text, users can ensure consistency across bug reports, feature requests, or other types of issues within a project, saving time and ensuring all necessary information is collected.

HISTORY

The GitHub CLI (gh) was officially released in late 2020, aiming to consolidate GitHub's features into a unified command-line interface. gh issue create has been a fundamental command since its early iterations, continually evolving with new options to support more nuanced and automated issue management workflows, reflecting GitHub's commitment to developer productivity and CLI-centric operations.

SEE ALSO

gh issue list(1), gh issue view(1), gh issue edit(1), gh pr create(1)

Copied to clipboard