gh

GitHub's official CLI tool, an open-source software for efficiently performing GitHub tasks in the terminal.

gh

Overview

gh is a command-line interface (CLI) tool officially developed by GitHub, allowing users to easily use GitHub's main features in a terminal environment. Since its first release in 2020, it has been widely adopted among developers, and through integration with Git commands, it enables direct local control of GitHub workflows such as issue management, pull requests, releases, and actions. As an open-source project, its integration with GitHub Actions has been strengthened, playing a key role in DevOps pipelines.

Main Content

Installation and Setup

gh supports major operating systems including macOS, Windows, and Linux, and can be easily installed via package managers (Homebrew, apt, scoop, etc.). After installation, authenticate your GitHub account with the gh auth login command, which securely connects via OAuth or SSH keys. Configuration files are stored in ~/.config/gh/ and can be customized to suit the user environment.

Core Commands

  • gh repo: Repository management such as creating, cloning, forking, and viewing repositories. Example: gh repo create my-project --public
  • gh pr: Creating, checking out, reviewing, and merging pull requests. Example: gh pr create --base main --title "New feature"
  • gh issue: Creating issues, viewing lists, and commenting. Example: gh issue list --label bug
  • gh run: Running GitHub Actions workflows and viewing logs. Example: gh run watch
  • gh release: Creating, uploading, and downloading releases. Example: gh release create v1.0 --notes "First release"
  • gh gist: Creating and listing Gists. Example: gh gist create file.txt

Workflow Integration

gh integrates naturally with Git commands. For example, after git push, you can immediately create a pull request with gh pr create, or switch to a specific PR's branch with gh pr checkout 123. Additionally, you can create custom shortcut commands with gh alias to boost productivity. Integration with GitHub Actions is particularly useful in CI/CD pipelines, allowing real-time monitoring of workflow status with the gh run command.

Extensibility and Plugins

gh supports an extension system, allowing installation of various plugins developed by the community. Activate additional features with the gh extension install command; for example, the gh copilot extension provides AI-based command suggestions. The official extension list is available on GitHub Marketplace, and users can also develop their own extensions.

Security and Authentication

gh supports authentication via HTTPS or SSH, with token-based authentication as the default. Check the current authentication status with gh auth status and end a session with gh auth logout. It also supports enterprise GitHub servers, configurable with gh auth login --hostname enterprise.example.com. It works smoothly in 2FA (two-factor authentication) environments.

Latest Trends

As of 2024-2025, gh is continuously updated to reflect new GitHub features. In 2024, the visualization of GitHub Actions workflows was enhanced, with the gh run view command providing more detailed logs and timelines. Additionally, integration with GitHub Copilot has expanded, with the gh copilot extension now officially supported, offering AI-based code suggestions and command autocompletion in the terminal. In early 2025, multi-account support was improved in gh v2.50 and above, adding the ability to manage multiple GitHub accounts simultaneously. In the open-source community, automation scripts using gh are increasing, particularly in CI/CD pipelines. Furthermore, performance optimizations have been made to gh, ensuring fast response times even in large repositories.

Related Topics

  • [[Git]]
  • [[GitHub Actions]]
  • [[Command-line interface]]
  • [[Open-source software]]
  • [[DevOps]]

---

AI-generated document · Improved together by the community