How to use the command `gh help` (with examples)
This article will guide you through various use cases of the gh help
command, which is a command-line interface (CLI) tool provided by GitHub. The gh help
command allows you to display information about the GitHub CLI commands and their usage.
Use case 1: Display general help
Code:
gh help
Motivation:
- You want to get a general overview of the
gh
command and how it works.
Explanation:
- The command
gh help
displays the general help information for the GitHub CLI command.
Example output:
gh is the GitHub CLI.
...
USAGE
gh <command> <subcommand> [flags]
CORE COMMANDS
help Display help about the GitHub CLI
config Manage configuration for the GitHub CLI
...
SEE ALSO
gh help <command> or gh <command> --help
Get help about any command or flag
Use case 2: Display help for the gh help
subcommand
Code:
gh help --help
Motivation:
- You want to understand the usage and available options for the
gh help
subcommand.
Explanation:
- The
gh help --help
command displays the help information specifically for thegh help
subcommand.
Example output:
Display help about the GitHub CLI command.
USAGE
gh help <command>
FLAGS
-h, --help Show help for command
AVAILABLE COMMANDS
alias, api, completion, config, feedback, help, issue, ...
Use case 3: Display help about environment variables that can be used with gh
Code:
gh help environment
Motivation:
- You want to learn about the environment variables that can be utilized with the
gh
command.
Explanation:
- Running the
gh help environment
command provides information about the environment variables that can be used in conjunction with thegh
command.
Example output:
Environment variables that can be set:
GH_HOME
Set the directory where gh should store configuration data.
GH_CONFIG_DIR
Set the directory where gh should find configuration data.
...
Use case 4: Display a markdown reference of all gh
commands
Code:
gh help reference
Motivation:
- You wish to obtain a markdown reference that lists all the available
gh
commands.
Explanation:
- The
gh help reference
command displays a markdown reference of all the GitHub CLI commands.
Example output:
All available gh commands:
COMMAND DESCRIPTION
alias Create command shortcuts
api Make an authenticated GitHub API request
completion Generate shell completion scripts
config Manage configuration for gh
feedback Create a new GitHub issue or pull request
help Display help about any command
...
Use case 5: Display help about formatting JSON output from gh
using jq
Code:
gh help formatting
Motivation:
- You want to learn about the formatting options available for JSON output when using
gh
with thejq
command-line tool.
Explanation:
- Running the
gh help formatting
command provides help information about formatting JSON output obtained from thegh
command using thejq
syntax.
Example output:
gh help formatting
Displays help about formatting JSON output with 'jq'.
Arguments:
<query>
A jq query for selecting fields to include in the output. (optional)
Flags:
-r, --raw-strings
Do not escape JSON strings in the output.
-c, --compact
Generate a compact JSON output.
...
Use case 6: Display help about using gh
with MinTTY
Code:
gh help mintty
Motivation:
- You want to find guidance on using the
gh
command with the MinTTY terminal.
Explanation:
- The
gh help mintty
command provides help information specifically about using thegh
command with MinTTY, which is an alternate terminal for Windows.
Example output:
MinTTY is not supported on your platform. If you believe this message is an error,
please raise an issue at https://github.com/cli/cli.
ERROR: unsupported platform
Use case 7: Display help for a subcommand
Code:
gh help subcommand
Motivation:
- You need help and information about a specific subcommand for the
gh
command.
Explanation:
- By replacing “subcommand” with the desired subcommand, you can get help about that specific subcommand using the
gh help <subcommand>
command.
Example output:
Display help information about the specific subcommand.
USAGE
gh help <subcommand>
Use case 8: Display help for a subcommand action
Code:
gh help pr create
Motivation:
- You want to get help and instructions about a particular action within a subcommand, such as creating a pull request (
pr create
).
Explanation:
- Using the
gh help <subcommand> <action>
command, you can view help information specifically about a particular action within a subcommand.
Example output:
Create a new pull request.
Usage:
gh pr create [flags]
...
Conclusion:
The gh help
command is a versatile tool that provides detailed help information and documentation about the GitHub CLI commands, subcommands, actions, and various usage scenarios. By utilizing the different options and arguments of the gh help
command, developers can easily access the information they need to maximize their productivity with the GitHub CLI.