关于 GitHub CLI
GitHub CLI 是用于从计算机的命令行使用 GitHub 的开源工具。 从命令行操作时,您可以使用 GitHub CLI 来节省时间并避免切换上下文。
入门指南
-
在 macOS、Windows 或 Linux 上安装 GitHub CLI。
-
In the command line, authenticate to GitHub.
gh auth login
To authenticate to your GitHub Enterprise Server instance, use the
--hostname
flag.gh auth login --hostname hostname
-
Start working with GitHub in the command line. For example, find an issue to work on with
gh issue status
orgh issue list --assignee @me
. Create a pull request withgh pr create
. Review a pull request withgh pr checkout
,gh pr diff
andgh 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, seegh 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 rungh prd
to quickly open a draft pull request. For more information, seegh 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."