Now that we have a functioning repository from the previous lesson, we’re ready to dive headfirst into the GitHub CLI’s commands. The best approach is to first familiarize ourselves with the command structure. At the core of the CLI, all commands follow a basic pattern.
gh <command> <subcommand> --flags
The primary alias for interacting with the GitHub CLI is gh. Executing gh alone will display a high-level overview of all available commands, as shown in the screenshot below.

Scrolling down, there’s a useful guide that shows an overview on the command syntax:
LEARN MORE
Use 'gh <command> <subcommand> --help' for more information about a command.
Read the manual at https://cli.github.com/manual
Deconstructing a Command
Let’s deconstruct a straightforward command like gh pr view 123 --web. This command opens a specific pull request in the browser by passing in a value. The majority of commands are going to follow this type of syntax.
ghis the CLI’s alias.pris a top-level command within the CLI.viewis a subcommand underpr.123represents a variable, in this case, pull request number 123.--webis a flag that can be used with theviewsubcommand to open the item in the browser instead of displaying it in the terminal.
Learning About Commands
In upcoming lessons, we’ll explore how to craft more complex commands. Remember, two invaluable resources are at your disposal: the GitHub CLI manual, which offers the most current information, and the --help flag which is an excellent quick-reference for command details.
