LinuxCommandLibrary

gh-label

Manage GitHub issue and pull request labels

TLDR

List labels for the repository in the current directory

$ gh label [[ls|list]]
copy

View labels for the repository in the current directory in the default web browser
$ gh label [[ls|list]] [[-w|--web]]
copy

Create a label with a specific name, description, and color in hexadecimal format for the repository in the current directory
$ gh label create [name] [[-d|--description]] "[description]" [[-c|--color]] [color_hex]
copy

Delete a label for the repository in the current directory, prompting for confirmation
$ gh label delete [name]
copy

Update the name and description for a specific label for the repository in the current directory
$ gh label edit [name] [[-n|--name]] [new_name] [[-d|--description]] "[description]"
copy

Clone labels from a specific repository into the repository in the current directory
$ gh label clone [owner]/[repository]
copy

Display help for a subcommand
$ gh label [subcommand] [[-h|--help]]
copy

SYNOPSIS

gh label <create|delete|edit|list> [flags]

PARAMETERS

create <name>
    Create a new label with given name

--color, -c <hex>
    Hex color code without # (e.g., 5319E7)

--description <text>
    Short description for the label

delete <names...>
    Delete one or more labels by name

edit <name>
    Edit properties of a label

--name <new-name>
    New name for the label (edit only)

list
    List all labels in the repository

--limit <int>
    Maximum number of labels to return

--json <fields>
    Output labels as JSON array of fields

-R, --repo [<HOST/>]OWNER/REPO
    Operate on specific repository

--help
    Show help for command

DESCRIPTION

gh label is a subcommand of the GitHub CLI (gh) that enables creating, editing, deleting, and listing labels in GitHub repositories from the command line. Labels categorize and prioritize issues, pull requests, and discussions with colors and descriptions.

Key subcommands: create adds new labels specifying name, hex color (e.g., CC317C), and optional description; edit updates name, color, or description; delete removes specified labels; list displays all labels with options for limiting output or JSON format.

Common flags like -R, --repo allow targeting any repository. Designed for scripting, automation in CI/CD pipelines, and repository maintenance without browser access. Requires gh authentication via gh auth login. Supports interactive prompts for missing inputs.

CAVEATS

Requires GitHub CLI installed and authenticated (gh auth login); write permissions needed for create/edit/delete; colors are 6-hex uppercase without #; operates on current Git repo context by default.

EXAMPLES

gh label create "bug" --color CC0000 --description "Something is not working"
gh label list --limit 5 --json name,color
gh label delete "wontfix" "invalid"
gh label edit high-priority --color 116329 --description "Must address immediately"

JSON FIELDS

Supported: name, color, description; use --json 'name,color,description' for scripting with jq(1).

HISTORY

Part of GitHub CLI since v0.5.0 (Feb 2020); evolved with JSON output in v1.0 (2021) and repo flag enhancements in v2.0+; actively maintained by GitHub for CLI standardization.

SEE ALSO

gh(1), gh-issue(1), gh-pr(1)

Copied to clipboard