GitHub CLI quickstart

Start using GitHub CLI to work with GitHub in the command line.

关于 GitHub CLI

GitHub CLI 是用于从计算机的命令行使用 GitHub 的开源工具。 从命令行操作时,您可以使用 GitHub CLI 来节省时间并避免切换上下文。

入门指南

  1. Install GitHub CLI on macOS, Windows, or Linux.

  2. In the command line, authenticate to GitHub.

    gh auth login

    To authenticate to your enterprise, use the --hostname flag.

    gh auth login --hostname hostname
  3. Start working with GitHub in the command line. For example, find an issue to work on with gh issue status or gh issue list --assignee @me. Create a pull request with gh pr create. Review a pull request with gh pr checkout, gh pr diff and gh pr review.

后续步骤

  • Tell GitHub CLI which text editor to use for commands that open a text editor. For example, enter gh config set editor "code -w" to set your preferred text editor to Visual Studio Code. For more information, see gh config set.

  • Define aliases for commands that you commonly run. For example, if you run gh alias set prd "pr create --draft", you will then be able to run gh prd to quickly open a draft pull request. For more information, see gh alias.

  • Create or add custom commands with GitHub CLI extensions. For more information, see "Using GitHub CLI extensions" and "Creating GitHub CLI extensions."

  • For more information about all of the commands that you can run with GitHub CLI, see "GitHub CLI reference."

此文档对您有帮助吗?

隐私政策

帮助我们创建出色的文档!

所有 GitHub 文档都是开源的。看到错误或不清楚的内容了吗?提交拉取请求。

做出贡献

或者, 了解如何参与。