LinuxCommandLibrary

gh

Interact with GitHub from the command line

TLDR

Clone a GitHub repository locally

$ gh repo clone [owner]/[repository]
copy

Create a new issue
$ gh issue create
copy

View and filter the open issues of the current repository
$ gh issue list
copy

View an issue in the default web browser
$ gh issue view [[-w|--web]] [issue_number]
copy

Create a pull request
$ gh pr create
copy

View a pull request in the default web browser
$ gh pr view [[-w|--web]] [pr_number]
copy

Check out a specific pull request locally
$ gh pr checkout [pr_number]
copy

Check the status of a repository's pull requests
$ gh pr status
copy

SYNOPSIS

gh command [flags]

PARAMETERS

auth login
    Authenticate with GitHub.

auth logout
    Log out of GitHub.

auth status
    Display authentication status.

browse
    Open a repository in the browser.

completion
    Generate shell completion scripts.

config
    Manage gh configuration.

issue
    Manage issues.

pr
    Manage pull requests.

repo
    Manage repositories.

workflow
    Manage GitHub Actions workflows.

--help
    Show help for command.

--version
    Show gh version.

DESCRIPTION

The `gh` command is the official GitHub Command Line Interface. It allows you to interact with GitHub directly from your terminal. It simplifies many common Git and GitHub workflows, letting you perform actions like creating repositories, opening pull requests, reviewing issues, and managing releases without needing to switch context to a web browser. `gh` authenticates with your GitHub account and uses the GitHub API to execute commands. It offers features like tab completion for commands and arguments, interactive prompts for simpler usage, and configuration options for customizing its behavior. It empowers developers to automate GitHub workflows, enhance their productivity, and integrate GitHub functionality into their existing terminal-based workflows. The tool is designed to be intuitive and easy to learn, making GitHub accessible to a wider range of users regardless of their experience level.

SUBCOMMANDS

gh has a wide range of subcommands, like `gh issue list` to list issues, or `gh pr create` to create pull requests. Every main subcommand has a --help command to show it's individual options and usage.

AUTHENTICATION

To function correctly, `gh` needs to be authenticated with your GitHub account. This is typically done using the `gh auth login` command, which will guide you through the process of granting the CLI access to your GitHub account.

CONFIGURATION

The `gh` CLI can be configured through command-line flags or through environment variables. This allows you to customize its behavior to match your preferences and workflows.

HISTORY

The `gh` CLI was initially developed by GitHub to provide a more convenient and efficient way to interact with GitHub from the command line. Before `gh`, developers often relied on a combination of `git` commands and manual interactions with the GitHub website. The development of `gh` was driven by the need to streamline common GitHub workflows and reduce the cognitive load of switching between different interfaces. The CLI has evolved over time, with new features and improvements being added based on user feedback and the changing needs of the GitHub community. Now it's an integral part of GitHub developer ecosystem.

SEE ALSO

git(1)

Copied to clipboard