该目录为 开发 gh 的相关文档

gh有关安装和使用方法,请访问gh 手册.

我们是如何对命令行语法进行文档化的

字面文字

对命令中无法更改的部分,使用纯文本。

例子: gh help此命令中需要参数帮助。

替换值

使用尖括号表示用户必须替换的值。尖括号内,不能包含其他表达式。

例子:

  • gh pr view <issue-number>

<issue-number>替换成发行号。

可选参数

将可选参数放在方括号中。如果用竖条分隔,可选的互斥参数。

例子:

  • gh pr checkout [--web]

参数--web是可选的。

  • gh pr view [<number> | <url>]

这个<number><url>参数是可选的。

所需的互斥参数

将所需的互斥参数放在大括号内,用竖条分隔参数。

例子:

  • gh pr {view | create}

重复性的参数

省略号表示可以多次出现的参数。

例子:

  • gh pr close <pr-number>...

Variable naming

对于多字变量,使用破折号(所有小写字母,都用破折号分隔)

例子:

  • gh pr checkout <issue-number>

其他示例

带占位符的可选参数:

  • command sub-command [<arg>]

具有互斥选项的必需参数:

  • command sub-command {<path> | <string> | literal}

具有互斥选项的可选参数:

  • command sub-command [<path> | <string>]

GitHub CLI & hub

GitHub CLI (gh)是2020 上半年出来的并提供了更无缝的方式 —— 从命令行与 GitHub 存储库进行交互。我们还知道,许多人对非常相似的hub项目,感兴趣,所以我们想澄清一些潜在的混淆点。

为什么不直接在 hub 上,构建gh?

我们竭力地去思考,是否继续在hub现有基础上再接再厉,并将其作为正式的 GitHub 项目采用。在权衡不同的可能性时,我们决定重新开始。hub可以安全地别名为git,会是一个冒险的假设。我们还希望该断则断,专注于 GitHub 工作流。而且hub让许多喜欢现有工具,并希望它以他们习惯的方式工作的用户,逐渐偏离的危险。

hub 的下一步?

GitHub CLI 团队专注于构建新工具gh,而hub,我们是不会关机或者做任何事情来改变它。这是一个开源项目,只要它得到维护并不断收到捐款,它就会继续存在。

什么意思, GitHub CLI 是官方,而 hub 非官方?

GitHub CLI 由一组代表 GitHub 人员,构建和维护。当它出现问题时,人们可以联系 GitHub 支持部门,或在问题跟踪器中,创建问题,GitHub 的员工将在那里做出响应。

hub是一个项目,其维护者恰好也是 GitHub 的员工。而他选择在他的业余时间,维护hub,就像我们的许多员工做开源项目一样。

我应该使用 ghhub?

译者:这句话,我都不想看,不用它,上传都困难。

~~我们无意强迫任何人使用 GitHub CLI 而不是hub.我们认为人们应该使用任何一套工具,让他们在使用 GitHub 时感到最快乐和最高效。

如果您打算使用一个工具作为 Git 本身的包装器,hub这可能是一个更好的选择gh.

如果您想要一个更加固执己见的工具,并希望从命令行帮助简化 GitHub 工作流,我们希望您使用gh.从那时起gh由 GitHub 的一个团队维护,我们打算响应人们的关注和需求,并根据人们随着时间的推移如何使用它来改进该工具。

GitHub CLI 并不打算完全取代hub而且可能永远不会,但我们希望使用 CLI 的绝大多数 GitHub 用户将在使用中发现越来越多的价值gh随着我们的不断改进。~~

Installing gh on Linux and BSD

从下载的软件包https://cli.github.com或来自https://github.com/cli/cli/releases被认为是官方二进制文件。我们关注流行的 Linux 发行版和以下 CPU 体系结构:i386, amd64, arm64, armhf.

其他安装源由社区维护,因此可能落后于我们的发布计划。

Official sources

Debian, Ubuntu Linux, Raspberry Pi OS (apt)

安装:

curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt update
sudo apt install gh

升级:

sudo apt update
sudo apt install gh

Fedora, CentOS, Red Hat Enterprise Linux (dnf)

安装:

sudo dnf config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo
sudo dnf install gh

升级:

sudo dnf update gh

openSUSE/SUSE Linux (zypper)

安装:

sudo zypper addrepo https://cli.github.com/packages/rpm/gh-cli.repo
sudo zypper ref
sudo zypper install gh

升级:

sudo zypper ref
sudo zypper update gh

Manual installation

Unofficial, community-supported methods

GitHub CLI 团队不维护以下软件包或存储库,因此我们无法提供对这些安装方法的支持。

Snap (do not use)

so many issues with Snap作为我们团队建议的 GitHub CLI 等应用程序的运行时机制永远不要安装 gh 作为一个单元.

Arch Linux

Arch Linux 用户可以从community repo:

sudo pacman -S github-cli

或者,使用unofficial AUR package从源代码构建 GitHub CLI。

Android

Android 7+用户可以通过Termux:

pkg install gh

FreeBSD

FreeBSD 用户可以从ports collection:

cd /usr/ports/devel/gh/ && make install clean

或通过pkg(8):

pkg install gh

NetBSD/pkgsrc

NetBSD 用户和网络上的用户platforms supported by pkgsrc可以安装gh package:

pkgin install gh

要从源代码安装,请执行以下操作:

cd /usr/pkgsrc/net/gh && make package-install

OpenBSD

在最新版本或从 7.0 开始的版本中,OpenBSD 用户可以从以下软件包安装:

pkg_add github-cli

Funtoo

Funtoo Linux 有一个自动生成的 github cli 包,位于dev-kit,可通过以下方式安装:

emerge -av github-cli

可通过同步回购协议,然后请求升级来完成升级:

ego sync
emerge -u github-cli

Gentoo

Gentoo Linux 用户可以从main portage tree:

emerge -av github-cli

升级可以通过更新 portage 树,然后请求升级来完成:

emerge --sync
emerge -u github-cli

Kiss Linux

Kiss Linux 用户可以从community repos:

kiss b github-cli && kiss i github-cli

Nix/NixOS

Nix/NixOS 用户可以从nixpkgs:

nix-env -iA nixos.gitAndTools.gh

openSUSE Tumbleweed

openSUSE Tumbleweed 用户可以从official distribution repo:

sudo zypper in gh

GitHub CLI project layout

在高层次上,这些领域构成了github.com/cli/cli项目:

  • cmd/ - main用于构建二进制文件的包,例如gh可执行
  • pkg/-大多数其他软件包,包括单个gh命令的实现
  • docs/-维护人员和贡献者的文档
  • script/-构建和发布脚本
  • internal/-Go软件包高度特定于我们的需求,因此是内部的
  • go.mod-此项目的外部Go依赖项,由Go在生成时自动获取

由于历史原因,一些辅助Go包处于项目的顶层:

  • api/-向GitHub API发出请求的主要实用程序
  • context/-不推荐:仅用于引用git远程
  • git/-从本地git存储库收集信息的实用程序
  • test/-不推荐:不要使用
  • utils/-不推荐:仅用于打印表输出

Command-line help text

跑步gh help issue list显示主题的帮助文本。在本例中,主题是一个特定的命令,每个命令的帮助文本都嵌入到该命令的源代码中。gh命令的命名约定为:

pkg/cmd/<command>/<subcommand>/<subcommand>.go

在上面的示例之后gh issue list命令(包括其帮助文本)位于pkg/cmd/issue/list/list.go

其他非特定于任何命令的帮助主题,例如gh help environment,在pkg/cmd/root/help_topic.go.

在我们的发布过程中,这些帮助主题是automatically converted到手册页并在下发布https://cli.github.com/manual/.

How GitHub CLI works

为了说明GitHub CLI在其典型操作模式下的工作方式,让我们构建项目,运行命令,然后讨论按顺序运行的代码。

  1. go run script/build.go-确保获取所有外部Go依赖项,然后编译cmd/gh/main.go归档bin/gh二进制的
  2. bin/gh issue list --limit 5-运行新建的bin/gh二进制(注意:在Windows上必须使用反斜杠,如bin\gh)并将以下参数传递给进程:["issue", "list", "--limit", "5"].
  3. func main()在…内cmd/gh/main.go是运行的第一个Go函数。传递给进程的参数可以通过os.Args.
  4. 这个main包使用以下命令初始化“root”命令root.NewCmdRoot()并向其发出执行命令rootCmd.ExecuteC().
  5. 这个root command表示顶层gh命令,并知道如何将执行分派给嵌套在其下的任何其他gh命令。
  6. 基于["issue", "list"]参数,则执行到达RunE街区cobra.Command在内部pkg/cmd/issue/list/list.go.
  7. 这个--limit 5将自动分析最初作为参数传递的标志,并将其值存储为opts.LimitResults.
  8. func listRun()调用,它负责实现gh issue list命令
  9. 该命令从githubapi等源收集信息,然后将最终输出写入标准输出和标准错误streams可在opts.IO.
  10. 程序执行现在返回到func main()属于cmd/gh/main.go。如果处理该命令时出现任何Go错误,则该函数将以非零退出状态中止该过程。否则,进程将以状态0结束,表示成功。

How to add a new command

  1. 首先,检查我们的问题追踪器,确认我们的团队已经批准了新司令部的计划。
  2. 为新命令创建包,例如,为新命令创建包gh boom创建以下目录结构:pkg/cmd/boom/
  3. 新包应该公开一个方法,例如。NewCmdBoom(),即接受*cmdutil.Factory键入并返回一个*cobra.Command.
    • 任何特定于此命令的逻辑都应该保存在命令包中,而不是添加到任何“全局”包中,如apiutils.
  4. 使用上一步中的方法生成命令并将其添加到命令树中,通常在NewCmdRoot()方法

How to write tests

这项任务可能很棘手。通常,gh命令执行的操作包括从当前目录的git存储库中查找信息、查询githubapi、扫描用户的~/.ssh/config文件、克隆或获取git存储库等。当然,在运行测试时,这些事情都不应该真正发生,除非您确信任何文件系统操作都严格限定在测试本身创建和维护的位置。避免实际运行诸如发出真正的API请求或向git命令,我们将它们存根。您应该看看在一些现有测试中是如何做到这一点的。

要使您的代码可测试,请编写设计为组合在一起的小型、独立的功能。在执行单个功能时,更喜欢使用表驱动测试来维护不同测试输入和期望的变化。

Releasing

我们的构建系统自动编译跨平台二进制文件并将其附加到任何名为vX.Y.Z。更改日志是generated from git commit log.

运行的正式版本的用户gh在他们的机器上,将在24小时内收到有关新版本的通知。

要测试生成系统,请发布一个名为vX.Y.Z-pre.0vX.Y.Z-rc.1。请注意,这样的版本仍然是公开的,但它将被标记为“预发布”,这意味着它永远不会显示为“最新”版本,也不会触发用户的升级通知。

General guidelines

  • 要发布的功能应在发布前至少一天进行审查和批准。
  • 功能发布应该增加次要版本号。

Tagging a new release

  1. git tag v1.2.3 && git push origin v1.2.3
  2. 等待几分钟以运行生成:https://github.com/cli/cli/actions
  3. 验证是否显示了版本并具有正确的资源:https://github.com/cli/cli/releases
  4. 扫描生成的发行说明,并通过在主题部分下对项目进行分组,选择性地添加人性化体验
  5. 验证营销网站是否已更新:https://cli.github.com
  6. (可选)删除与此版本相关的任何预发布

成功构建将导致跨多个存储库进行更改:

如果构建失败,没有一种干净的方法可以重新运行它。最简单的方法是重新开始,删除GitHub上的部分发行版并重新发布标记。请注意,这可能会中断已收到升级通知的用户或工具。如果功能发布及其二进制文件已经存在,那么最好尝试手动修复失败的特定工作流任务。根据故障类型做出最佳判断。

Release locally for debugging

可以创建本地版本进行测试,而无需在发布页面上创建任何官方内容。

  1. 确保安装了GoReleaser:brew install goreleaser
  2. goreleaser --skip-validate --skip-publish --rm-dist
  3. 在下面找到构建的产品dist/.

Installation from source

  1. 验证是否已安装 Go 1.16+

    $ go version
    

    如果go未安装,请按照上的说明操作the Go website.

  2. 克隆此存储库

    $ git clone https://github.com/cli/cli.git gh-cli
    $ cd gh-cli
    
  3. 构建和安装

    Unix-like systems

    # installs to '/usr/local' by default; sudo may be required
    $ make install
    
    # or, install to a different location
    $ make install prefix=/path/to/gh
    

    Windows

    # build the `bin\gh.exe` binary
    > go run script\build.go
    

    Windows 上没有可用的安装步骤。

  4. gh version检查它是否有效。

    Windows

    bin\gh version检查它是否有效。

Cross-compiling binaries for different platforms

您可以使用安装了 Go 的任何平台,来构建用于其他平台或 CPU 体系结构的二进制文件。这是通过设置环境变量(如 GOOS 和 GOARCH)实现的。

例如,编译gh —— 32 位 Raspberry Pi 操作系统的二进制文件:

# on a Unix-like system:
$ GOOS=linux GOARCH=arm GOARM=7 CGO_ENABLED=0 make clean bin/gh
# on Windows, pass environment variables as arguments to the build script:
> go run script\build.go clean bin\gh GOOS=linux GOARCH=arm GOARM=7 CGO_ENABLED=0

运行go tool dist list,列出所有支持的 GOOS/GOARCH 值。

提示:要减小生成的二进制文件的大小,可以使用GO_LDFLAGS="-s -w"。这将忽略用于调试的符号表。请参阅supported linker flags.

Triage role

当我们在GitHub CLI上打开更多问题和请求时,我们决定每周轮换一次。最初的期望是,本周担任该职位的人员每天在这项工作上的时间不超过2小时;我们可以根据需要改进它。

Expectations for incoming issues

所有传入问题都需要增强, 缺陷文件标签

被认为是被分流的,增强问题至少需要以下一个附加标签:

  • 果心:保留给核心CLI团队的工作
  • 需要帮助:我们将接受捐款的工作
  • 需要设计:需要用户体验设计师输入才能继续进行的工作
  • 需要调查:需要核心团队解开谜团才能继续进行的工作
  • 需要用户输入:需要记者提供更多信息才能继续进行的工作

被认为是被分流的,缺陷问题需要一个严重性标签:以下之一p1, p2p3

如需了解更详细的怎样要对问题进行分类,请参阅问题分类流程图在下面

Expectations for community pull requests

要被视为分流,传入的拉取请求应:

  • 检查是否有相应的错误需要帮助问题
  • 检查基本质量:构建是否通过?是否增加了测试?
  • 检查冗余:是否已经有一个PR处理此问题?

一旦对PR进行了分类,应将其移动到需要审查项目委员会的专栏。

如需了解更详细的怎样要对问题进行分类,请参阅PR分流流程图在下面

Issue triage flowchart

  • 这个可以直接关闭吗?
    • e、 g.垃圾邮件/垃圾
    • 闭嘴
  • 我们不想这样做吗?
    • e、 g.已经讨论过不想做或重复的问题
    • 点评结束
  • 我们可以接受外部捐款吗?
    • e、 g.这项任务相对简单,但我们团队中没有人有足够的带宽来承担这项任务
    • 确保线程包含新用户获取此消息所需的所有上下文
    • 添加help wanted标签
    • 考虑加入good first issue标签
  • 我们想这样做吗?
    • 评论承认它
    • 添加core标签
    • 如果这是应该很快发布的内容,请添加到“项目待办事项”列
  • 这很有趣,但需要讨论吗?
    • 标签needs-design如果需要设计输入,ping
    • 标签needs-investigation如果在采取行动之前需要进行工程研究
  • 是否需要问题作者提供更多信息?
    • 向用户询问详细信息
    • 添加needs-user-input标签
  • 这是一个使用/支持问题吗?
    • 提供一些说明/解决方法并关闭

Pull request triage flowchart

  • 可以直接关闭吗?
    • e、 g.垃圾邮件/垃圾
  • 我们不想这样做吗?
    • 点评结束
  • 这是否有趣,但需要讨论,并且没有参考问题?
    • 提出问题
  • 这是我们想要包括的东西吗?
    • 加上needs review

Weekly PR audit

为了不让我们的公开PR名单失控(20+总PR几个月前有多个PRs),每周尝试审核打开的PRs,目的是将其合并和/或关闭。处理每一次PR可能需要做太多的工作,但即使是接近完成一些也很有帮助。

对于每个PR,请询问:

  • 这是否太陈旧(超过两个月还是冲突太多)?以评论结束
  • 这真的很接近但作者缺席吗?推送提交完成,请求审阅
  • 这是在等待分流吗?通过PR分类流程

Useful aliases

本要点为第一响应者提供了一些有用的别名:

https://gist.github.com/vilmibm/ee6ed8a783e4fef5b69b2ed42d743b1a

Examples

我们希望我们的项目是一个安全且令人鼓舞的开源环境。以下是一些如何以同理心回应或结束问题/PR的示例:

gh

命令行与 GitHub 合为一体。

Core commands

Actions commands

Additional commands

Options

--version
Show gh version

Examples

$gh repo clone cli/cli
$gh pr checkout 321

gh actions

欢迎使用命令行上的 GitHub Actions。

GitHub CLI 与 Actions 集成,帮助您管理和运行工作流。

与工作流运行交互 gh run list: 列出最近的工作流运行 gh run view: 查看工作流运行,或其中某个作业的详细信息 gh run watch: 在工作流执行时,观察其运行 gh run rerun: 重新运行失败的工作流运行 gh run download: 下载运行生成的工件

要查看更多帮助,请运行gh help run <subcommand>

与工作流文件交互 gh workflow list: 列出存储库中的所有工作流文件 gh workflow view: 查看工作流文件的详细信息 gh workflow enable: 启用工作流文件 gh workflow disable: 禁用工作流文件 gh workflow run: 触发工作流文件的工作流 u 调度运行

要查看更多帮助,请运行gh help workflow <subcommand>

See also

gh alias

别名,可用于为 gh 命令

  • 创建快捷方式
  • 组合多个命令。

运行 gh help alias set 了解更多信息。

Commands

See also

gh alias delete

删除别名

gh alias delete <alias>

See also

gh alias list

gh alias list

此命令打印出 gh 配置为使用的所有别名。

See also

gh alias set

gh alias set <alias> <expansion> [flags]

定义一个在调用时,将扩展为完整 gh 命令的单词。

扩展可以指定其他参数和标志。如果扩展包含位置占位符,如“$1”,则会适当插入别名后面的额外参数。否则,额外的参数将附加到展开的命令中。

使用 - 作为扩展参数,从 standard input 读取扩展字符串。这有助于在定义扩展时,避免引用问题。

如果扩展以 ! 开头或者,如果给定 -shell,则扩展是一个 shell 表达式,调用别名时,将通过“sh”解释器执行。这允许通过 管道重定向链接 多个命令。

Options

-s, --shell
定义个 alias 传递给 shell 解释器,r

Examples

# note: Command Prompt on Windows 要双引号

$ gh alias set pv 'pr view'
$ gh pv -w 123  #=> gh pr view -w 123

$ gh alias set bugs 'issue list --label=bugs'
$ gh bugs

$ gh alias set homework 'issue list --assignee @me'
$ gh homework

$ gh alias set epicsBy 'issue list --author="$1" --label="epic"'
$ gh epicsBy vilmibm  #=> gh issue list --author="vilmibm" --label="epic"

$ gh alias set --shell igrep 'gh issue list --label="$1" | grep "$2"'
$ gh igrep epic foo  #=> gh issue list --label="epic" | grep "foo"

See also

gh api

gh api <endpoint> [flags]

向 GitHub API 发出经过身份验证的 HTTP 请求,并打印响应。

endpoint 参数应该是 GitHub API v3 endpoint 的路径,或者是访问 GitHub API v4 的graphql

endpoint 参数中的占位符值{owner}{repo}{branch}将替换成当前目录存储库中的值。请注意,在某些 shell(例如 PowerShell)中,可能需要用{…}的值,放在引号中,以防止 shell 对花括号应用特殊含义。

默认的 HTTP 请求方法通常为GET,如果添加了任何参数,则为POST。用--method覆盖默认。

-f/--raw-field传递key=value格式的一个或多个,用于向请求负载,添加静态字符串参数。要添加非字符串或其他动态值,请参见--field。请注意,添加请求参数将自动将请求方法切换为 POST。要改 GET,请使用--method GET.

这个-F/--field标志具有基于值格式的魔法类型转换:

  • 文本值truefalsenull和整数,被转换为适当的 JSON 类型;
  • 占位符值{owner}{repo}{branch}由当前目录存储库中的值填充;
  • 如果该值以@开头,则该值的其余部分将被解释为,读取值的文件名。传递-则从标准输入读取。

对于 GraphQL 请求,除queryoperationName之外的所有字段都被解释为 GraphQL 变量。

原始请求主体可以通过--input指定的文件,从外部传递。传递-则从标准输入读取。在此模式下,通过--field指定的参数。被序列化为 URL 查询参数。

--paginate模式下,将按顺序请求所有结果页,直到没有更多结果页为止。对于 GraphQL 请求,这要求原始查询接受一个$endCursor: String变量,之后它从一个集合,获取pageInfo{ hasNextPage, endCursor }字段集。

Options

--cache <duration>
缓存一个响应, e.g. "3600s", "60m", "1h"
-F, --field <key=value>
添加一个类型参数,格式是 key=value
-H, --header <key:value>
添加一个 HTTP 请求头,格式是 key=value
--hostname <string>
请求的 GitHub 主址 (默认为 "github.com")
-i, --include
将 HTTP 响应头也输出
--input <file>
file 作为 HTTP 请求的主体 (使用 "-" 可以从标准输入读取)
-q, --jq <string>
使用 jq 语法,查询响应的值
-X, --method <string>
HTTP 方法
--paginate
发出额外的 HTTP 请求,获取所有的结果页
-p, --preview <strings>
GitHub API 预览版本的功能
-f, --raw-field <key=value>
添加一个字符串参数,格式是 key=value
--silent
不打印
-t, --template <string>
用模板格式化响应

Examples

# 列出,repo 的 releases 
$ gh api repos/{owner}/{repo}/releases

# 发布一个 issue 评论
$ gh api repos/{owner}/{repo}/issues/123/comments -f body='Hi from CLI'

# 为 GET 请求,添加参数
$ gh api -X GET search/issues -f q='repo:cli/cli is:open remote'

# 自定义 HTTP header
$ gh api -H 'Accept: application/vnd.github.v3.raw+json' ...

# GitHub API 预览版本的功能
$ gh api --preview baptiste,nebula ...

# 打印 response 中特殊字段
$ gh api repos/{owner}/{repo}/issues --jq '.[].title'

# 模板化输出
$ gh api repos/{owner}/{repo}/issues --template \
  '{{range .}}{{.title}} ({{.labels | pluck "name" | join ", " | color "yellow"}}){{"\n"}}{{end}}'

# 列出,releases with GraphQL
$ gh api graphql -F owner='{owner}' -F name='{repo}' -f query='
  query($name: String!, $owner: String!) {
    repository(owner: $owner, name: $name) {
      releases(last: 3) {
        nodes { tagName }
      }
    }
  }
'

# 列出,一个用户所有的存储库
$ gh api graphql --paginate -f query='
  query($endCursor: String) {
    viewer {
      repositories(first: 100, after: $endCursor) {
        nodes { nameWithOwner }
        pageInfo {
          hasNextPage
          endCursor
        }
      }
    }
  }
'

See also

gh auth

管理 gh 的身份验证状态。

Commands

See also

gh auth login

gh auth login [flags]

通过 GitHub 主机进行身份验证。

默认身份验证模式是基于 web 的浏览器流。

或者,使用--with-token传进令牌。而令牌所需的最小范围为:repo, read:org

--scopes 标志接受以逗号分隔的范围列表,这些范围是您希望 gh 凭据具有的范围。如果不存在,此命令将确保 gh 可以访问最小范围集。

Options

-h, --hostname <string>
身份验证的 GitHub 主址
-s, --scopes <strings>
权限范围
-w, --web
打开浏览器,进行身份验证
--with-token
从标准输入读取令牌

Examples

# 交互式登录
$ gh auth login

# 直接令牌登录

$ gh auth login --with-token < mytoken.txt

# 企业用户版本

$ gh auth login --hostname enterprise.internal

See also

gh auth logout

gh auth logout [flags]

删除 GitHub 主机的身份验证。

以交互方式或通过–hostname 指定的方式,此命令删除主机的身份验证配置。

Options

-h, --hostname <string>
所要登出的服务主机

Examples

$ gh auth logout
# => select what host to log out of via a prompt

$ gh auth logout --hostname enterprise.internal
# => log out of specified host

See also

gh auth refresh

gh auth refresh [flags]

扩展或修复,存储凭据的权限范围

--scopes 标志接受以逗号分隔的范围列表,这些范围是您希望 gh 凭据具有的范围。如果不存在,此命令将确保 gh 可以访问最小范围集。

Options

-h, --hostname <string>
The GitHub 主机
-s, --scopes <strings>
权限范围

Examples

$ gh auth refresh --scopes write:org,read:public_key
# => 打开浏览器,添加 write:org 和 read:public_key 权限

$ gh auth refresh
# => 打开浏览器,确保具有最小权限

See also

gh auth setup-git

配置 git,这样就可以使用 GitHub CLI ,作为凭据帮助器

gh auth setup-git [flags]

Options

-h, --hostname <string>
配置 git 的 主机网址

See also

gh auth status

gh auth status [flags]

验证并显示有关身份验证状态的信息。

此命令将测试 gh 知道的每个 GitHub 主机的身份验证状态,并报告任何问题。

Options

-h, --hostname <string>
检查的主机
-t, --show-token
展示 身份令牌

See also

gh browse

gh browse [<number> | <path>] [flags]

在 web 浏览器中,打开 GitHub 存储库。

Options

-b, --branch <string>
换分支
-c, --commit
打开最后的 commit
-n, --no-browser
给 URL,不打开浏览器
-p, --projects
打开,库项目
-R, --repo <[HOST/]OWNER/REPO>
[HOST/]OWNER/REPO 格式的库
-s, --settings
打开,repository settings
-w, --wiki
打开,repository wiki

Examples

$gh browse
#=>打开当前存储库的主页

$gh browse 217
#=>打开未结问题或拉取请求 217

$gh browse --settings
#=>打开存储库设置

$gh browse main.go:312
#=>打开 main.go 第 312 行

$gh browse main.go --branch main
#=>打开 main.go 进入 main 分支

See also

gh codespace

连接并管理您的代码空间

GitHub Codespaces 通过 Visual Studio Code 或你的浏览器访问云托管的开发环境。

Commands

See also

gh codespace code

在 Visual Studio Code 中,打开代码空间

gh codespace code [flags]

Options

-c, --codespace <string>
名字
--insiders
Visual Studio Code 内部版本

See also

gh codespace cp

gh codespace cp [-e] [-r] <sources>... <dest>

cp 命令在本地和远程文件系统之间,复制文件。

与 UNIX 一样的cp命令,第一个参数指定,,最后一个参数指定,目标;如果目标是目录,则可以在第一个参数之后,指定其他源。

这个--recursive,如果任何源是目录,则需要标记。

任何文件名参数上的remote:前缀,表示它引用远程(代码空间)计算机的文件系统。它相对于远程用户的主目录进行解析。

默认情况下,远程文件名按字面解释。若是写有--expand标志,则每个此类参数均按scp方式处理:作为要在远程计算机上计算的 Bash 表达式,需要对 tildes、大括号、glob、环境变量和 backticks 进行扩展。(译者:看例子)

为了安全起见,不要对不受信任的用户,提供这个标志;具体看见 https://lwn.net/Articles/835962/ ,讨论讨论。

Options

-c, --codespace <string>
名字
-e, --expand
在远程 shell上,展开远程的(多个)文件名
-r, --recursive
递归复制目录

Examples

$ gh codespace cp -e README.md 'remote:/workspaces/$RepositoryName/'
$ gh codespace cp -e 'remote:~/\*.go' ./gofiles/
$ gh codespace cp -e 'remote:/workspaces/myproj/go.{mod,sum}' ./gofiles/

See also

gh codespace create

创建一个代码空间

gh codespace create [flags]

Options

-b, --branch <string>
repository 分支
--idle-timeout <duration>
在 codespace 停止之前,不活动的时间, e.g. "10m", "1h"
-m, --machine <string>
VM 硬件规格
-r, --repo <string>
拥有者的库名: user/repo
-s, --status
展示 post-create 命令和 dotfiles

See also

gh codespace delete

删除代码空间

gh codespace delete [flags]

Options

--all
删除所有
-c, --codespace <string>
名称
--days <N>
删除过去 N 天
-f, --force
强制删除
-r, --repo <repository>
删除一个库

See also

gh codespace list

列出你的代码空间

gh codespace list [flags]

Options

-q, --jq <expression>
jq 表达式,过滤 JSON 输出
--json <fields>
JSON 输出特殊字段
-L, --limit <int>
列出的数量
-t, --template <string>
模板化输出

See also

gh codespace logs

访问代码空间日志

gh codespace logs [flags]

Options

-c, --codespace <string>
名字
-f, --follow
日志跟随滚动

See also

gh codespace ports

列出代码空间中的端口

gh codespace ports [flags]

Commands

Options

-c, --codespace <string>
名字
-q, --jq <expression>
jq 表达式,过滤 JSON 输出
--json <fields>
JSON 输出特殊字段
-t, --template <string>
模板化输出

See also

gh codespace ports forward

转发端口

gh codespace ports forward <remote-port>:<local-port>...

Options inherited from parent commands

-c, --codespace <string>
名字

See also

gh codespace ports visibility

更改转发端口的可见性

gh codespace ports visibility <port>:{public|private|org}...

Options inherited from parent commands

-c, --codespace <string>
名字

Examples

gh codespace ports visibility 80:org 3000:private 8000:public

See also

gh codespace ssh

SSH 到一个代码空间

gh codespace ssh [<flags>...] [-- <ssh-flags>...] [<command>]

Options

-c, --codespace <string>
名字
-d, --debug
调试数据装入文件
--debug-file <string>
文件日志的路径
--profile <string>
所使用的 SSH profile 名称
--server-port <int>
SSH 服务器端口号 (0 => pick unused)

See also

gh codespace stop

停止运行代码空间

gh codespace stop [flags]

Options

-c, --codespace <string>
名字

See also

gh completion

gh completion -s <shell>

为 GitHub CLI 命令生成, shell 补全脚本。

通过包管理器安装 GitHub CLI 时,可能不需要额外的 shell 配置,获得补全支持。若是 Homebrew,请参阅https://docs.brew.sh/Shell-Completion

如果需要手动设置补全,请按照以下说明操作。具体的配置文件位置可能因您的系统而异。在测试补全是否正常工作之前,请确保重启 shell。

bash

首先,确保您使用包管理器,安装了bash-completion

之后,将此添加到您的~/.bash_profile:

eval "$(gh completion -s bash)"

zsh

产生_gh 补全脚本,并将其放在您的$fpath:

gh completion -s zsh > /usr/local/share/zsh/site-functions/_gh

确保您的文档~/.zshrc中存在以下内容:

autoload -U compinit
compinit -i

建议使用 Zsh 版本 5.7 或更高版本。

fish

产生gh.fish 补全脚本:

gh completion -s fish > ~/.config/fish/completions/gh.fish

PowerShell

使用以下命令,打开您的配置文件脚本:

mkdir -Path (Split-Path -Parent $profile) -ErrorAction SilentlyContinue
notepad $profile

添加代码行,并保存文件:

Invoke-Expression -Command $(gh completion -s powershell | Out-String)

Options

-s, --shell <string>
Shell type: {bash|zsh|fish|powershell}

See also

gh config

显示或更改 gh 的配置设置。

当前遵循的设置:

  • git_protocol:用于 git clone 和 push 操作的协议(默认值:https
  • 编辑器:用于编写文本的文本编辑器程序
  • 提示:在终端中切换交互式提示(默认值:已启用
  • pager:发送标准输出的终端程序
  • http_unix_socket:指向 unix 套接字的路径,通过该套接字进行 http 连接
  • 浏览器:用于打开 URL 的 web 浏览器

Commands

See also

gh config get

打印给定配置密钥的值

gh config get <key> [flags]

Options

-h, --host <string>
Get per-host setting

Examples

$gh config get git_protocol https

See also

gh config list

打印配置键和值的列表

gh config list [flags]

Options

-h, --host <string>
Get per-host configuration

See also

gh config set

使用给定密钥的值更新配置

gh config set <key> <value> [flags]

Options

-h, --host <string>
Set per-host setting

Examples

$ gh config set editor vim
$ gh config set editor "code --wait"
$ gh config set git_protocol ssh --host github.com
$ gh config set prompt disabled

See also

gh extension

GitHub CLI 扩展是提供附加 gh 命令的存储库。

扩展存储库的名称必须以gh-开头,并且必须包含同名的可执行文件。所有参数都传递给gh <extname>,然后转发到gh-<extname>扩展的可执行文件。

扩展不能覆盖任何核心 gh 命令。

请参阅上的可用扩展名列表 https://github.com/topics/gh-extension

Commands

See also

gh extension create

创建一个新的扩展名

gh extension create [<name>] [flags]

Options

--precompiled <string>
预编译扩展。可能的值: go, other

Examples

# 交互式
gh extension create

# 创建一个 script-based 扩展
gh extension create foobar

# 创建一个 Go 扩展
gh extension create --precompiled=go foobar

# 创建一个 non-Go precompiled 扩展
gh extension create --precompiled=other foobar

See also

gh extension install

gh extension install <repository>

在本地安装 GitHub 存储库,作为 GitHub CLI 扩展。

存储库参数以owner/repo格式以及完整 URL 指定。当存储库未托管在 github 上时,URL 格式非常有用。

要从当前目录,安装正在开发中的扩展,请使用.作为存储库参数的值。

请参阅上的可用扩展名列表https://github.com/topics/gh-extension

Examples

$ gh extension install owner/gh-extension
$ gh extension install https://git.example.com/owner/gh-extension
$ gh extension install .

See also

gh extension list

列出已安装的扩展命令

gh extension list

See also

gh extension remove

删除已安装的扩展

gh extension remove <name>

See also

gh extension upgrade

升级已安装的扩展

gh extension upgrade {<name> | --all} [flags]

Options

--all
更新所有
--force
强制更新

See also

gh gist

与 GitHub gist 合作。

Commands

See also

gh gist clone

gh gist clone <gist> [<directory>] [-- <gitflags>...]

本地克隆 GitHub gist。

要点可以以下格式之一作为参数提供:

git clone的选项,在--之后传递。

See also

gh gist create

gh gist create [<filename>... | -] [flags]

创建具有给定内容的新 GitHub gist。

GIST 可以从一个或多个文件创建。或者,传递-作为文件名,从标准输入读取。

默认情况下,GIST 是保密的;使用--public将其公开列出。

Options

-d, --desc <string>
描述
-f, --filename <string>
标准输入,给个文件名
-p, --public
公开 (default: secret)
-w, --web
gist 链接,打开浏览器

Examples

# 上传 'hello.py' 作为公开的 gist
$ gh gist create --public hello.py

# 带描述
$ gh gist create hello.py -d "my Hello-World program in Python"

# 带多个文件
$ gh gist create hello.py world.py cool.txt

# 要标准输入
$ gh gist create -

# 管道输入
$ cat cool.txt | gh gist create

See also

gh gist delete

删除 gist

gh gist delete {<id> | <url>}

See also

gh gist edit

编辑一个 GIST

gh gist edit {<id> | <url>} [flags]

Options

-a, --add <string>
新增一个文件
-f, --filename <string>
选择一个文件编辑

See also

gh gist list

列出你的 gist

gh gist list [flags]

Options

-L, --limit <int>
列出的数量
--public
只给出 public gists
--secret
只给出 secret gists

See also

gh gist view

gh gist view [<id> | <url>] [flags]

查看给定的 gist,或从最近的 gist 中选择。

Options

-f, --filename <string>
展示单个文件
--files
列出文件名列表
-r, --raw
原始内容
-w, --web
浏览器打开

See also

gh gpg-key

管理在 GitHub 帐户中,注册的 GPG 密钥

Commands

See also

gh gpg-key add

将 GPG 密钥,添加到 GitHub 帐户

gh gpg-key add [<key-file>]

See also

gh gpg-key list

列出 GitHub 帐户中的 GPG 密钥

gh gpg-key list

See also

gh help

gh help [command]

提供帮助。简单输入 gh help [path to command]

See also

gh environment

GH_TOKEN, GITHUB_TOKEN(按优先顺序):github.com API 请求的身份验证令牌。设置此选项可避免提示进行身份验证,并优先于以前存储的凭据。

GH_ENTERPRISE_TOKENGITHUB_ENTERPRISE_TOKEN(按优先顺序):用于向 GITHUB ENTERPRISE 发出 API 请求的身份验证令牌。设置此选项时,还要设置 GH_HOST。

GH_HOST:为命令指定 GitHub 主机名,不在现有存储库的上下文中时,假定为“github.com“主机。

GH_REPO:指定 GitHub 存储库(“[HOST/]OWNER/REPO“格式),用于在本地存储库上运行的命令。

GH_EDITOR, GIT_EDITOR, VISUAL, EDITOR(按优先顺序):用于编写文本的编辑器工具。

GH_BROWSER, BROWSER(按优先顺序):用于打开链接的 web 浏览器。

DEBUG:可以设为任何值,以启用标准错误的详细输出。包括值api or oauth,以打印有关 HTTP 请求或身份验证流的详细信息。

GH_PAGER, PAGER(按优先顺序):发送标准输出的终端寻呼程序,例如: less

GLAMOUR_STYLE:用于渲染 Markdown 的样式。https://github.com/charmbracelet/glamour#styles

NO_COLOR:可以设为任何值,以避免打印颜色输出的 ANSI 转义序列。

CLICOLOR:设置为0,以禁用在输出中打印 ANSI 颜色。

CLICOLOR_FORCE:设置0以外的值,以保持输出中的 ANSI 颜色,即使输出是通过管道传输的。

GH_FORCE_TTY:可以设为任何值,以强制终端样式输出,即使输出被重定向。当该值为数字时,它将被解释为 viewport 中可用的列数。当该值为百分比时,将根据当前视口中,可用的列数,来应用该值。

GH_NO_UPDATE_NOTIFIER:可以设为任何值,以禁用更新通知。默认情况下,gh 每 24 小时检查一次新版本,如果发现较新版本,则会显示标准错误的升级通知。

GH_CONFIG_DIR:GH 将存储配置文件的目录。默认值:$XDG_CONFIG_HOME/gh$HOME/.config/gh

See also

gh formatting

一些 gh 命令支持将数据导出为 JSON,以替代通常的基于行的纯文本输出。这适用于将结构化数据传递给脚本。JSON 输出是通过--json选项,后跟要获取的字段列表。使用不带值的标志来获取可用字段的列表。

这个--jq选项接受 jq 语法的 查询,并且只打印与查询匹配的结果值。这相当于,将输出管道化到jq -r,但不要求在系统上安装 jq 实用程序。要了解有关查询语法的详细信息,请参阅:https://stedolan.github.io/jq/manual/v1.6/

--template,作为 Go 模板,自然是程序 JSON 数据。有关 Go 模板的语法,请参见:https://golang.org/pkg/text/template/

模板中,提供以下功能:

  • autocolor:例如color,但仅向终端发射颜色
  • color <style> <input>:使用https://github.com/mgutz/ansi,对输入进行颜色化
  • join <sep> <list>:使用分隔符,连接列表中的值
  • pluck <field> <list>:从输入中的所有项,收集字段值
  • tablerow <fields>...:将输出中的字段,作为表格垂直对齐
  • tablerender:就地呈现由 tablerow 添加的字段
  • timeago <time>:呈现相对于现在的时间戳
  • timefmt <format> <time>:使用 Go Time.Format函数,格式化时间戳
  • truncate <length> <input>:确保输入,符合长度

Examples

$ gh issue list --json number,title --template \
  '{{range .}}{{tablerow (printf "#%v" .number | autocolor "green") .title}}{{end}}'

# format a pull request using multiple tables with headers
$ gh pr view 3519 --json number,title,body,reviews,assignees --template \
  '{{printf "#%v" .number}} {{.title}}

  {{.body}}

  {{tablerow "ASSIGNEE" "NAME"}}{{range .assignees}}{{tablerow .login .name}}{{end}}{{tablerender}}
  {{tablerow "REVIEWER" "STATE" "COMMENT"}}{{range .reviews}}{{tablerow .author.login .state .body}}{{end}}
  '

See also

gh mintty

MinTTY 是 Git for Windows 默认附带的终端仿真器。它在 gh 提示用户输入部分,有些已知的问题。

有一些变通方法可以让 gh 与 MinTTY 合作:

  • 重新安装 Git for Windows,选中启用对伪控制台的实验支持(Enable experimental support for pseudo consoles)

  • 使用不同的终端仿真器和 Git for Windows,如 Windows 终端。您可以从任何终端仿真器运行C:\Program Files\Git\bin\bash.exe,在没有 MinTTY 的情况下,继续使用 Git For Windows 中的所有工具。

  • 使用 winpty 作为 gh 调用的前缀,例如:winpty gh auth login。注意:这可能会导致一些 UI 错误。

See also

gh reference

gh reference

gh actions

了解如何使用 GitHub Actions

gh alias <command>

创建命令快捷方式

gh alias delete <alias>

删除别名

gh alias list

列出你的别名

gh alias set <alias> <expansion> [flags]

为 gh 命令,创建快捷方式

-s, --shell   定义个 alias 传递给 shell 解释器,r

gh api <endpoint> [flags]

发出,经过身份验证的 GitHub API 请求

    --cache duration        缓存一个响应, e.g. "3600s", "60m", "1h"
-F, --field key=value       添加一个类型参数,格式是 key=value
-H, --header key:value      添加一个 HTTP 请求头,格式是 key=value
    --hostname string       请求的 GitHub 主址 (default "github.com")
-i, --include               将 HTTP 响应头也输出
    --input file            file 作为 HTTP 请求的主体 (使用 "-" 可以从标准输入读取)
-q, --jq string             使用 jq 语法,查询响应的值
-X, --method string         HTTP 方法 (默认 "GET")
    --paginate              发出额外的 HTTP 请求,获取所有的结果页
-p, --preview strings       GitHub API 预览版本的功能
-f, --raw-field key=value   添加一个字符串参数,格式是 key=value
    --silent                不打印
-t, --template string       用模板格式化响应

gh auth <command>

登录、注销和刷新您的身份验证

gh auth login [flags]

通过 GitHub 主机进行身份验证

-h, --hostname string   身份验证的 GitHub 主址
-s, --scopes strings    权限范围
-w, --web               打开浏览器,进行身份验证
    --with-token        从标准输入读取令牌

gh auth logout [flags]

注销 GitHub 主机

-h, --hostname string   身份登出的 GitHub 主址

gh auth refresh [flags]

刷新存储的身份验证凭据

-h, --hostname string   身份验证的 GitHub 主址
-s, --scopes strings    权限范围

gh auth setup-git [flags]

配置 git,以将 GitHub CLI 用作凭据帮助器

-h, --hostname string   配置 git 的 主机网址

gh auth status [flags]

查看身份验证状态

-h, --hostname string   检查的主机
-t, --show-token        展示 身份令牌

gh browse [<number> | <path>] [flags]

在浏览器中,打开存储库

-b, --branch string   换分支
-c, --commit          打开最后的 commit
-n, --no-browser      给 URL,不打开浏览器
-p, --projects        打开 projects
-s, --settings        打开 settings
-w, --wiki            打开 wiki

gh codespace

连接,并管理您的代码空间

gh codespace code [flags]

在 Visual Studio Code 中打开代码空间

-c, --codespace string   名字
    --insiders           Use the insiders version of Visual Studio Code

gh codespace cp [-e] [-r] <sources>... <dest>

在本地和远程文件系统之间,复制文件

-c, --codespace string   名字
-e, --expand             在远程 shell上,展开远程的(多个)文件名
-r, --recursive          递归复制目录

gh codespace create [flags]

创建一个代码空间

-b, --branch string           分支
    --idle-timeout duration   在 codespace 停止之前,不活动的时间, e.g. "10m", "1h"
-m, --machine string          VM 硬件规格
-r, --repo string             拥有者的库名: user/repo
-s, --status                  展示 post-create 命令和 dotfiles

gh codespace delete [flags]

删除代码空间

    --all                删除所有
-c, --codespace string   名字
    --days N             删除过去 N 天
-f, --force              强制删除
-r, --repo repository    删除一个库

gh codespace list [flags]

列出你的代码空间

-q, --jq expression     jq 表达式,过滤 JSON 输出
    --json fields       JSON 输出特殊字段
-L, --limit int         Maximum number of codespaces to list (default 30)
-t, --template string   模板化输出

gh codespace logs [flags]

访问代码空间日志

-c, --codespace string   名字
-f, --follow             日志跟随滚动

gh codespace ports [flags]

列出代码空间中的端口

-q, --jq expression     jq 表达式,过滤 JSON 输出
    --json fields       JSON 输出特殊字段
-t, --template string   模板化输出

gh codespace ports forward <remote-port>:<local-port>...

转发端口

gh codespace ports visibility <port>:{public|private|org}...

更改转发端口的可见性

gh codespace ssh [<flags>...] [-- <ssh-flags>...] [<command>]

SSH 到一个代码空间

-c, --codespace string    名字
-d, --debug               调试数据装入文件
    --debug-file string   文件日志的路径
    --profile string      所使用的 SSH profile 名称
    --server-port int     SSH 服务器端口号 (0 => pick unused)

gh codespace stop [flags]

停止运行代码空间

-c, --codespace string   名字

gh completion -s <shell>

生成 shell 完成脚本

-s, --shell string   Shell type: {bash|zsh|fish|powershell}

gh config <command>

管理 gh 的配置

gh config get <key> [flags]

打印给定配置密钥的值

-h, --host string   获取每个 host 的 setting

gh config list [flags]

打印配置键和值的列表

-h, --host string   获取每个 host 的 configuration

gh config set <key> <value> [flags]

使用给定密钥的值更新配置

-h, --host string   设置每个 host 的 setting

gh extension

管理 gh 扩展

gh extension create [<name>] [flags]

创建一个新的扩展名

--precompiled string   预编译扩展。可能的值: go, other

gh extension install <repository>

从存储库安装 gh 扩展

gh extension list

列出已安装的扩展命令

gh extension remove <name>

删除已安装的扩展

gh extension upgrade {<name> | --all} [flags]

升级已安装的扩展

--all     更新所有
--force   强制更新

gh gist <command>

与 GitHub gist(要点) 合作

gh gist clone <gist> [<directory>] [-- <gitflags>...]

本地克隆要点

gh gist create [<filename>... | -] [flags]

创造一个新的要点

-d, --desc string       描述
-f, --filename string   标准输入,给个文件名
-p, --public            公开 (default: secret)
-w, --web               gist 链接,打开浏览器

gh gist delete {<id> | <url>}

删除要点

gh gist edit {<id> | <url>} [flags]

编辑一个要点

-a, --add string        新增一个文件
-f, --filename string   选择一个文件编辑

gh gist list [flags]

列出你的要点

-L, --limit int   Maximum number of gists to fetch (default 10)
    --public      Show only public gists
    --secret      Show only secret gists

gh gist view [<id> | <url>] [flags]

要点

-f, --filename string   展示单个文件
    --files             列出文件名列表
-r, --raw               原始内容
-w, --web               浏览器打开

gh gpg-key <command>

管理 GPG 密钥

gh gpg-key add [<key-file>]

将 GPG 密钥添加到 GitHub 帐户

gh gpg-key list

列出 GitHub 帐户中的 GPG 密钥

gh issue <command>

管理问题

gh issue close {<number> | <url>}

结案

gh issue comment {<number> | <url>} [flags]

创建新的问题注释

-b, --body string      提供主体内容。不填,也会提示
-F, --body-file file   读取文件,输入主体内容 (使用 "-" 可以从标准输入读取)
-e, --editor           通过 editor 添加主体
-w, --web              用浏览器打开网络链接,添加主体

gh issue create [flags]

创刊

-a, --assignee login   通过 login 分配人员。使用 @me 自我分配。
-b, --body string      提供主体内容。不填,也会提示
-F, --body-file file   读取文件,输入主体内容 (使用 "-" 可以从标准输入读取)
-l, --label name       添加标签
-m, --milestone name   通过 name,添加 issue 到 name 里程牌
-p, --project name     通过 name,添加 issue 到 name 项目
    --recover string   一次失败创建,带来的恢复输入
-t, --title string     提供一个标题。不填,也会提示
-w, --web              浏览器打开,创建 issue

gh issue delete {<number> | <url>}

删除问题

gh issue edit {<number> | <url>} [flags]

编辑问题

    --add-assignee login      通过 login 分配人员。使用 @me 自我分配。
    --add-label name          添加标签
    --add-project name        通过 name,添加 issue 到 name 项目
-b, --body string             设置新的主体内容.
-F, --body-file file          读取文件,输入主体内容 (使用 "-" 可以从标准输入读取)
-m, --milestone name          用 name,编辑下里程碑
    --remove-assignee login   移除 login 的人员配置. 使用 @me 就移除自己
    --remove-label name       移除 name 标签
    --remove-project name     移除 name 项目
-t, --title string            设置新的标题.

gh issue list [flags]

列出并筛选此存储库中的问题

-a, --assignee string    过滤项:assignee
-A, --author string      过滤项:author
-q, --jq expression      jq 表达式,过滤 JSON 输出
    --json fields        JSON 输出特殊字段
-l, --label strings      过滤项:labels
-L, --limit int          Maximum number of issues to fetch (default 30)
    --mention string     过滤项:mention
-m, --milestone number   过滤项:milestone number or `title`
-S, --search query       query 搜索 issue
-s, --state string       过滤项:state: {open|closed|all} (default "open")
-t, --template string    模板化输出
-w, --web                浏览器打开,列出 issue(s)

gh issue reopen {<number> | <url>}

重新发行

gh issue status [flags]

显示相关问题的状态

-q, --jq expression     jq 表达式,过滤 JSON 输出
    --json fields       JSON 输出特殊字段
-t, --template string   模板化输出

gh issue transfer {<number> | <url>} <destination-repo>

将问题转移到另一个存储库

gh issue view {<number> | <url>} [flags]

看问题

-c, --comments          View issue comments
-q, --jq expression     jq 表达式,过滤 JSON 输出
    --json fields       JSON 输出特殊字段
-t, --template string   模板化输出
-w, --web               Open an issue in the browser

gh pr <command>

管理拉取请求

gh pr checkout {<number> | <url> | <branch>} [flags]

查看 git 中的 pull 请求

-b, --branch string        本地分支名 (default: the name of the head branch)
    --detach               以一种分离 HEAD 的状态,查看 PR
-f, --force                重设本地分支为最新的PR
    --recurse-submodules   在 checkout 之后,更新所有的 submodules

gh pr checks [<number> | <url> | <branch>] [flags]

显示单个 PR 的 CI 状态

-w, --web   浏览器打开

gh pr close {<number> | <url> | <branch>} [flags]

关闭拉取请求

-d, --delete-branch   关闭 PR 之后,删除本地与远程的分支

gh pr comment [<number> | <url> | <branch>] [flags]

创建新的 PR 评论

-b, --body string      提供主体内容。不填,也会提示
-F, --body-file file   读取文件,输入主体内容 (使用 "-" 可以从标准输入读取)
-e, --editor           通过 editor 添加主体
-w, --web              用浏览器打开网络链接,添加主体

gh pr create [flags]

创建拉取请求

-a, --assignee login       通过 login 分配人员。使用 @me 自我分配。
-B, --base branch          要合并到的分支
-b, --body string          PR 的主体内容
-F, --body-file file       读取文件,输入主体内容
-d, --draft                草稿版
-f, --fill                 不用提示,使用 commit 的信息填入 title/body
-H, --head branch          包含你 commits 的分支 (default: current branch)
-l, --label name           添加标签
-m, --milestone name       通过 name,添加 PR 到 name 里程牌
    --no-maintainer-edit   禁用维护人员修改 PR 
-p, --project name         将 pull request 添加到 name 项目
    --recover string       一次失败创建,带来的恢复输入
-r, --reviewer handle      PR 审查人员
-t, --title string         添加 标题
-w, --web                  浏览器打开

gh pr diff [<number> | <url> | <branch>] [flags]

查看拉取请求中的更改

--color string   在 diff 输出中,使用颜色: {always|never|auto} (default "auto")
--patch          以 patch 格式,展示 diff

gh pr edit [<number> | <url> | <branch>] [flags]

编辑拉取请求

    --add-assignee login      通过 login 分配人员。使用 @me 自我分配
    --add-label name          添加标签
    --add-project name        将 pull request 添加到 name 项目
    --add-reviewer login      通过 login ,添加审查人员.
-B, --base branch             更改 PR 的基分支
-b, --body string             设置新的主体内容.
-F, --body-file file          读取文件,输入主体内容 (使用 "-" 可以从标准输入读取)
-m, --milestone name          编辑 name 里程牌
    --remove-assignee login   移除 login 的人员配置. 使用 @me 就移除自己
    --remove-label name       移除 name 标签
    --remove-project name     移除 name 项目的 PR
    --remove-reviewer login   通过 login ,移除审查人员.
-t, --title string            设置新的标题.

gh pr list [flags]

列出并筛选此存储库中的请求

-a, --assignee string   过滤项:assignee
-A, --author string     过滤项:author
-B, --base string       过滤项:base branch
-d, --draft             过滤项:draft state
-H, --head string       过滤项:head branch
-q, --jq expression     jq 表达式,过滤 JSON 输出
    --json fields       JSON 输出特殊字段
-l, --label strings     过滤项:labels
-L, --limit int         Maximum number of items to fetch (default 30)
-S, --search query      Search pull requests with query
-s, --state string      过滤项:state: {open|closed|merged|all} (default "open")
-t, --template string   模板化输出
-w, --web               Open the browser to list the pull requests

gh pr merge [<number> | <url> | <branch>] [flags]

合并拉取请求

    --admin            即便条件不达标,用管理员权限合并
    --auto             条件符合,自动合并
-b, --body text        合并的主体内容
-F, --body-file file   读取文件,输入主体内容 (使用 "-" 可以从标准输入读取)
-d, --delete-branch    合并后,删除本地与远程分支
    --disable-auto     禁止自动合并
-m, --merge            合并
-r, --rebase           变基
-s, --squash           将多个提交变成一个,再合并
-t, --subject text     合并提交的主题

gh pr ready [<number> | <url> | <branch>]

将 PR 标记为已准备好进行审查

gh pr reopen {<number> | <url> | <branch>}

重新打开拉取请求

gh pr review [<number> | <url> | <branch>] [flags]

向拉取请求添加审阅

-a, --approve           批准 pull request
-b, --body string       指定一个审查的主体内容
-F, --body-file file    读取文件,输入主体内容 (使用 "-" 可以从标准输入读取)
-c, --comment           给出评论
-r, --request-changes   要求 PR 修改

gh pr status [flags]

显示相关拉取请求的状态

-q, --jq expression     jq 表达式,过滤 JSON 输出
    --json fields       JSON 输出特殊字段
-t, --template string   模板化输出

gh pr view [<number> | <url> | <branch>] [flags]

查看拉取请求

-c, --comments          查看 pull request 评论
-q, --jq expression     jq 表达式,过滤 JSON 输出
    --json fields       JSON 输出特殊字段
-t, --template string   模板化输出
-w, --web               浏览器打开

gh release <command>

管理 GitHub 发布

gh release create [<tag>] [<files>...]

创建一个新版本

    --discussion-category string   开始指定主题分类的讨论
-d, --draft                        一个草稿版本
    --generate-notes               自动生成,release 的 标题与笔记
-n, --notes string                 Release 笔记
-F, --notes-file file              用文件,读笔记 (使用 "-" 可以从标准输入读取)
-p, --prerelease                   预览版
    --target branch                指定的分支或是完整的 commit SHA (default: main branch)
-t, --title string                 Release 标题

gh release delete <tag> [flags]

删除发布

-y, --yes   跳过提示

gh release download [<tag>] [flags]

下载发布资产

-A, --archive format        下载的格式 (zip or tar.gz)
-D, --dir string            下载的位置 (default ".")
-p, --pattern stringArray   只下载符合 glob 匹配模式的资源

gh release list [flags]

在存储库中列出发布

-L, --limit int   Maximum number of items to fetch (default 30)

gh release upload <tag> <files>... [flags]

将资产上载到发布

--clobber   覆盖同名资源

gh release view [<tag>] [flags]

查看有关发布的信息

-q, --jq expression     jq 表达式,过滤 JSON 输出
    --json fields       JSON 输出特殊字段
-t, --template string   模板化输出
-w, --web               浏览器打开

gh repo <command>

创建、克隆、分叉和查看存储库

gh repo archive [<repository>] [flags]

归档存储库

-y, --confirm   跳过提示

gh repo clone <repository> [<directory>] [-- <gitflags>...]

在本地克隆存储库

gh repo create [<name>] [flags]

创建一个新的存储库

-c, --clone                 Clone 新的存储库到当前目录
-d, --description string    存储库的描述
    --disable-issues        禁用 issues
    --disable-wiki          禁用 wiki
-g, --gitignore string      指定一个 gitignore 的模板
-h, --homepage URL          主页URL
    --internal              内部可见
-l, --license string        指定开源的协议
    --private               私有存储库
    --public                公开存储库
    --push                  推送本地的 commits 到新的存储库
-r, --remote string         指定 remote 名称
-s, --source string         指定存储库的源代码路径e
-t, --team name             可以访问存储库的组织名字
-p, --template repository   让新的存储库,基于 一个模板存储库生成

gh repo delete [<repository>] [flags]

删除存储库

--confirm   直接通过提示

gh repo edit [<repository>] [flags]

编辑存储库设置

    --add-topic strings        添加 存储库 标签主题
    --allow-forking            允许被 fork
    --default-branch name      设置默认的分支
    --delete-branch-on-merge   当 pull requests 被合并,删除 HEAD 分支
-d, --description string       存储库的描述
    --enable-auto-merge        启动 auto-merge(自动合并) 功能
    --enable-issues            启用 issues
    --enable-merge-commit      可以用 merge commit,合并 PR
    --enable-projects          启用 projects
    --enable-rebase-merge      可用变基(rebase)的方式合并 PR
    --enable-squash-merge      可用,将多个commit变为一个的方式,合并PR
    --enable-wiki              启用 wiki
-h, --homepage URL             主页URL
    --remove-topic strings     移除存储库的标签主题
    --template                 可将存储库当成,模板存储库
    --visibility string        将存储库的可见性改为 {public,private,internal}

gh repo fork [<repository>] [-- <gitflags>...] [flags]

创建存储库的分支

--clone                Clone the fork {true|false}
--org string           在一个组织内,创建副本
--remote               要添加远程(上级)存储库吗 {true|false}
--remote-name string   Specify a name for a fork's new remote. (default "origin")

gh repo list [<owner>] [flags]

列出用户或组织拥有的存储库

    --archived          仅展示存档的存储库
    --fork              仅展示副本存储库
-q, --jq expression     jq 表达式,过滤 JSON 输出
    --json fields       JSON 输出特殊字段
-l, --language string   主编程语言的过滤
-L, --limit int         Maximum number of repositories to list (default 30)
    --no-archived       不要存档的存储库
    --private           仅展示私有存储库
    --public            仅展示公开的存储库
    --source            仅展示非副本的存储库
-t, --template string   模板化输出
    --topic string      标题主题的过滤

gh repo rename [<new-name>] [flags]

重命名存储库

-y, --confirm   跳过提示,直接确定

gh repo sync [<destination-repository>] [flags]

同步存储库

-b, --branch string   同步的分支 (default: main branch)
    --force           强制同步
-s, --source string   源存储库

gh repo view [<repository>] [flags]

查看存储库

-b, --branch string     显示特定分支
-q, --jq expression     jq 表达式,过滤 JSON 输出
    --json fields       JSON 输出特殊字段
-t, --template string   模板化输出
-w, --web               浏览器打开

gh run <command>

查看有关工作流运行的详细信息

gh run cancel [<run-id>]

取消工作流运行

gh run download [<run-id>] [flags]

下载工作流运行生成的工件

-D, --dir string         下载的目录 (default ".")
-n, --name stringArray   仅下载匹配文件名的工件

gh run list [flags]

列出最近的工作流运行

-q, --jq expression     jq 表达式,过滤 JSON 输出
    --json fields       JSON 输出特殊字段
-L, --limit int         Maximum number of runs to fetch (default 20)
-t, --template string   模板化输出
-w, --workflow string   工作流的过滤

gh run rerun [<run-id>]

重新运行失败的运行

gh run view [<run-id>] [flags]

查看工作流运行的摘要

    --exit-status       Exit with non-zero status if run failed
-j, --job string        查看一个特定的 job ID
-q, --jq expression     jq 表达式,过滤 JSON 输出
    --json fields       JSON 输出特殊字段
    --log               查看 完整的日志
    --log-failed        查看运行失败的日志
-t, --template string   模板化输出
-v, --verbose           展示 job 步骤
-w, --web               浏览器打开

gh run watch <run-id> [flags]

观察跑步直到完成,并显示其进度

    --exit-status    运行失败,退出代码 非零
-i, --interval int   刷新的时间间隙 (default 3)

gh secret <command>

管理 GitHub 机密

gh secret list [flags]

列出秘密

-e, --env string   环境的机密
-o, --org string   组织的机密
-u, --user         用户的机密

gh secret remove <secret-name> [flags]

揭秘

-e, --env string   移除环境的机密
-o, --org string   移除组织的机密
-u, --user         移除用户的机密

gh secret set <secret-name> [flags]

创建或更新机密

-b, --body string                         机密内容 (reads from standard input if not specified)
-e, --env environment                     设置发布环境的机密
-f, --env-file file                       加载 secret 名与值 (dotenv 格式文件)
    --no-store                            打印 encrypted, base64-encoded 值,而不是在 Github 上存储
-o, --org organization                    设置组织的机密
-r, --repos repositories                  能访问到一个组织或用户机密,列出这样的存储库
-u, --user                                设置用户的机密
-v, --visibility {all|private|selected}   设置一个组织机密的可见性: {all|private|selected} (default "private")

gh ssh-key <command>

管理 SSH 密钥

gh ssh-key add [<key-file>] [flags]

向 GitHub 帐户添加 SSH 密钥

-t, --title string   密钥的 标题

gh ssh-key list

列出 GitHub 帐户中的 SSH 密钥

gh workflow <command>

查看有关 GitHub Actions 工作流的详细信息

gh workflow disable [<workflow-id> | <workflow-name>]

禁用工作流

gh workflow enable [<workflow-id> | <workflow-name>]

启用工作流

gh workflow list [flags]

列出工作流

-a, --all         展示所有,即便是禁用的工作流
-L, --limit int   Maximum number of workflows to fetch (default 50)

gh workflow run [<workflow-id> | <workflow-name>] [flags]

为给定工作流,创建 workflow_dispatch 事件。

-F, --field key=value       key=value 模式的字符串参数,遵守 @ 语法
    --json                  通过 STDIN,读取 JSON 格式的工作流输入
-f, --raw-field key=value   key=value 模式的字符串参数
-r, --ref string            想要运行的 分支与 tag 下的工作流文件

gh workflow view [<workflow-id> | <workflow-name> | <filename>] [flags]

查看工作流摘要

-r, --ref string   The branch or tag name which contains the version of the workflow file you'd like to view
-w, --web          浏览器打开
-y, --yaml         查看工作流的 yaml 文件

See also

gh issue

处理 GitHub 问题

Commands

Options

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

Examples

$ gh issue list
$ gh issue create --label bug
$ gh issue view --web

See also

gh issue close

关闭 issue

gh issue close {<number> | <url>}

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

See also

gh issue comment

创建新的问题评论

gh issue comment {<number> | <url>} [flags]

Options

-b, --body <string>
提供主体内容。不填,也会提示
-F, --body-file <file>
文件读取主体内容 (用"-" 的话,就从标准输入读取)
-e, --editor
通过 editor 添加主体
-w, --web
用浏览器打开网络链接,添加主体

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

Examples

$ gh issue comment 22 --body "I was able to reproduce this issue, lets fix it."

See also

gh issue create

创建 issue

gh issue create [flags]

Options

-a, --assignee <login>
通过 login 分配人员。使用 "@me" 自我分配。
-b, --body <string>
提供主体内容。不填,也会提示
-F, --body-file <file>
文件读取主体内容 (用"-" 的话,就从标准输入读取)
-l, --label <name>
通过 name,添加标签
-m, --milestone <name>
通过 name,添加 issue 到 name 里程牌
-p, --project <name>
通过 name,添加 issue 到 name 项目
--recover <string>
一次失败创建,带来的恢复输入
-t, --title <string>
提供一个标题。不填,也会提示
-w, --web
浏览器打开,创建 issue

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

Examples

$ gh issue create --title "I found a bug" --body "Nothing works"
$ gh issue create --label "bug,help wanted"
$ gh issue create --label bug --label "help wanted"
$ gh issue create --assignee monalisa,hubot
$ gh issue create --assignee "@me"
$ gh issue create --project "Roadmap"

See also

gh issue delete

删除问题

gh issue delete {<number> | <url>}

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

See also

gh issue edit

编辑问题

gh issue edit {<number> | <url>} [flags]

Options

--add-assignee <login>
通过 login,添加 关联的用户。使用 "@me" 关联自己.
--add-label <name>
通过 name,添加标签
--add-project <name>
通过 name,添加 issue 到 name 项目
-b, --body <string>
设置新的主体内容.
-F, --body-file <file>
文件读取主体内容 (用"-" 的话,就从标准输入读取)
-m, --milestone <name>
用 name,编辑下里程碑
--remove-assignee <login>
移除 login 的人员配置. 使用 "@me" 就移除自己
--remove-label <name>
移除 name 标签
--remove-project <name>
移除 name 项目
-t, --title <string>
设置新的标题.

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

Examples

$ gh issue edit 23 --title "I found a bug" --body "Nothing works"
$ gh issue edit 23 --add-label "bug,help wanted" --remove-label "core"
$ gh issue edit 23 --add-assignee "@me" --remove-assignee monalisa,hubot
$ gh issue edit 23 --add-project "Roadmap" --remove-project v1,v2
$ gh issue edit 23 --milestone "Version 1"
$ gh issue edit 23 --body-file body.txt

See also

gh issue list

列出,并筛选此存储库中的问题

gh issue list [flags]

Options

-a, --assignee <string>
Filter by assignee
-A, --author <string>
Filter by author
-q, --jq <expression>
jq 表达式,过滤 JSON 输出
--json <fields>
JSON 输出特殊字段
-l, --label <strings>
Filter by labels
-L, --limit <int>
Maximum number of issues to fetch
--mention <string>
Filter by mention
-m, --milestone <number>
Filter by milestone number or `title`
-S, --search <query>
Search issues with query
-s, --state <string>
Filter by state: {open|closed|all}
-t, --template <string>
模板化输出
-w, --web
浏览器打开,列出 issue(s)

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

Examples

$ gh issue list -l "bug" -l "help wanted"
$ gh issue list -A monalisa
$ gh issue list -a "@me"
$ gh issue list --web
$ gh issue list --milestone "The big 1.0"
$ gh issue list --search "error no:assignee sort:created-asc"

See also

gh issue reopen

重新打开

gh issue reopen {<number> | <url>}

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

See also

gh issue status

显示 issue 的状态

gh issue status [flags]

Options

-q, --jq <expression>
jq 表达式,过滤 JSON 输出
--json <fields>
JSON 输出特殊字段
-t, --template <string>
模板化输出

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

See also

gh issue transfer

将问题转移到另一个存储库

gh issue transfer {<number> | <url>} <destination-repo>

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

See also

gh issue view

gh issue view {<number> | <url>} [flags]

显示有关问题的标题、正文和其他信息。

使用--web,改为在 web 浏览器中打开问题。

Options

-c, --comments
View issue comments
-q, --jq <expression>
jq 表达式,过滤 JSON 输出
--json <fields>
JSON 输出特殊字段
-t, --template <string>
模板化输出
-w, --web
Open an issue in the browser

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

See also

gh pr

使用 GitHub 拉请求

Commands

Options

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

Examples

$ gh pr checkout 353
$ gh pr create --fill
$ gh pr view --web

See also

gh pr checkout

查看 git 中的 PR

gh pr checkout {<number> | <url> | <branch>} [flags]

Options

-b, --branch <string>
本地分支名 (默认: the name of the head branch)
--detach
以一种分离 HEAD 的状态,查看 PR
-f, --force
重设本地分支为最新的PR
--recurse-submodules
在 checkout 之后,更新所有的 submodules

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

See also

gh pr checks

gh pr checks [<number> | <url> | <branch>] [flags]

显示单个 PR 的 CI 状态。

在没有参数的情况下,将选择属于当前分支的请求。

Options

-w, --web
Open the web browser to show details about checks

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

See also

gh pr close

关闭拉取请求

gh pr close {<number> | <url> | <branch>} [flags]

Options

-d, --delete-branch
关闭 PR 之后,删除本地与远程的分支

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

See also

gh pr comment

gh pr comment [<number> | <url> | <branch>] [flags]

创建新的 PR 评论。

在没有参数的情况下,将选择属于当前分支的请求。

使用“–web“,开在 web 浏览器。

Options

-b, --body <string>
提供主体内容。不填,也会提示
-F, --body-file <file>
文件读取主体内容 (用"-" 的话,就从标准输入读取)
-e, --editor
通过 editor 添加主体
-w, --web
用浏览器打开网络链接,添加主体

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

Examples

$ gh pr comment 22 --body "This looks great, lets get it deployed."

See also

gh pr create

gh pr create [flags]

在 GitHub 上,创建拉取请求(PR)。

当当前分支未完全推送到 git 远程时,将出现一个提示,询问将分支推送到何处,并提供一个fork 基本存储库的选项。使用--head明确跳过任何 fork 或 push 行为。

提示还将要求 PR 的标题和主体内容。使用--title--body可以跳过,或者使用--fill从 git commits 中,自动填充这些值。

通过引用 PR 主体内容中的 issue ,将 issue 链接到 PR 。如果主体内容提到Fixes #123Closes #123,合并 PR 时,引用的 issue 将自动关闭。

默认情况下,对基本存储库具有写访问权限的用户,可以将新 commit 推送到 PR 的头分支。使用--no-maintainer-edit禁用此选项。

Options

-a, --assignee <login>
通过 login 分配人员。使用 "@me" 自我分配。
-B, --base <branch>
要合并到的分支
-b, --body <string>
PR 的主体内容
-F, --body-file <file>
读取文件,输入主体内容
-d, --draft
草稿版
-f, --fill
不用提示,使用 commit 的信息填入 title/body
-H, --head <branch>
包含你 commits 的分支 (default: current branch)
-l, --label <name>
添加标签
-m, --milestone <name>
通过 name,添加 PR 到 name 里程牌
--no-maintainer-edit
禁用维护人员修改 PR
-p, --project <name>
将 pull request 添加到 name 项目
--recover <string>
一次失败创建,带来的恢复输入
-r, --reviewer <handle>
PR 审查人员
-t, --title <string>
添加 标题
-w, --web
浏览器打开

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

Examples

$ gh pr create --title "The bug is fixed" --body "Everything works again"
$ gh pr create --reviewer monalisa,hubot  --reviewer myorg/team-name
$ gh pr create --project "Roadmap"
$ gh pr create --base develop --head monalisa:feature

See also

gh pr diff

gh pr diff [<number> | <url> | <branch>] [flags]

查看拉取请求中的更改。

在没有参数的情况下,将选择属于当前分支的请求。

Options

--color <string>
在 diff 输出中,使用颜色: {always|never|auto}
--patch
以 patch 格式,展示 diff

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

See also

gh pr edit

gh pr edit [<number> | <url> | <branch>] [flags]

编辑拉取请求。

在没有参数的情况下,将选择属于当前分支的请求。

Options

--add-assignee <login>
通过 login,添加 关联的用户。使用 "@me" 关联自己.
--add-label <name>
通过 name,添加标签
--add-project <name>
将 pull request 添加到 name 项目
--add-reviewer <login>
通过 login ,添加审查人员.
-B, --base <branch>
更改 PR 的基分支
-b, --body <string>
设置新的主体内容.
-F, --body-file <file>
文件读取主体内容 (用"-" 的话,就从标准输入读取)
-m, --milestone <name>
编辑 name 里程牌
--remove-assignee <login>
移除 login 的人员配置. 使用 "@me" 就移除自己
--remove-label <name>
移除 name 标签
--remove-project <name>
移除 name 项目的 PR
--remove-reviewer <login>
通过 login ,移除审查人员.
-t, --title <string>
设置新的标题.

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

Examples

$ gh pr edit 23 --title "I found a bug" --body "Nothing works"
$ gh pr edit 23 --add-label "bug,help wanted" --remove-label "core"
$ gh pr edit 23 --add-reviewer monalisa,hubot  --remove-reviewer myorg/team-name
$ gh pr edit 23 --add-assignee "@me" --remove-assignee monalisa,hubot
$ gh pr edit 23 --add-project "Roadmap" --remove-project v1,v2
$ gh pr edit 23 --milestone "Version 1"

See also

gh pr list

列出并筛选此存储库中的请求

gh pr list [flags]

Options

-a, --assignee <string>
Filter by assignee
-A, --author <string>
Filter by author
-B, --base <string>
Filter by base branch
-d, --draft
Filter by draft state
-H, --head <string>
Filter by head branch
-q, --jq <expression>
jq 表达式,过滤 JSON 输出
--json <fields>
JSON 输出特殊字段
-l, --label <strings>
Filter by labels
-L, --limit <int>
Maximum number of items to fetch
-S, --search <query>
Search pull requests with query
-s, --state <string>
Filter by state: {open|closed|merged|all}
-t, --template <string>
模板化输出
-w, --web
Open the browser to list the pull requests

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

Examples

# 列出 PRs,作者是你
$ gh pr list --author "@me"

# 列出 PRs,关联你的
$ gh pr list --assignee "@me"

# 列出 PRs ,bug 标签, 多个标签组合
$ gh pr list --label bug --label "priority 1"

# 列出 PRs,使用 search 语法
$ gh pr list --search "status:success review:required"

# 浏览器打开
$ gh pr list --web

See also

gh pr merge

gh pr merge [<number> | <url> | <branch>] [flags]

在 GitHub 上,合并拉取请求。

在没有参数的情况下,将选择属于当前分支的请求。

Options

--admin
即便条件不达标,用管理员权限合并
--auto
条件符合,自动合并
-b, --body <text>
合并的主体内容
-F, --body-file <file>
文件读取主体内容 (用"-" 的话,就从标准输入读取)
-d, --delete-branch
合并后,删除本地与远程分支
--disable-auto
禁止自动合并
-m, --merge
合并
-r, --rebase
变基
-s, --squash
将多个提交变成一个,再合并
-t, --subject <text>
合并提交的主题

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

See also

gh pr ready

gh pr ready [<number> | <url> | <branch>]

将 PR 标记为已准备好,进行审查

在没有参数的情况下,属于当前分支的请求被标记为 ready。

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

See also

gh pr reopen

重新打开拉取请求

gh pr reopen {<number> | <url> | <branch>}

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

See also

gh pr review

gh pr review [<number> | <url> | <branch>] [flags]

将一个审阅添加到请求中。

在没有参数的情况下,当前分支的请求被审查。

Options

-a, --approve
批准 pull request
-b, --body <string>
指定一个审查的主体内容
-F, --body-file <file>
文件读取主体内容 (用"-" 的话,就从标准输入读取)
-c, --comment
给出评论
-r, --request-changes
要求 PR 修改

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

Examples

# 批准
$ gh pr review --approve

# 给评论
$ gh pr review --comment -b "interesting"

# 指定 123 PR,添加一个审查
$ gh pr review 123

# 要求 修改
$ gh pr review 123 -r -b "needs more ASCII art"

See also

gh pr status

显示相关拉取请求的状态

gh pr status [flags]

Options

-q, --jq <expression>
jq 表达式,过滤 JSON 输出
--json <fields>
JSON 输出特殊字段
-t, --template <string>
模板化输出

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

See also

gh pr view

gh pr view [<number> | <url> | <branch>] [flags]

显示标题、正文和 PR 的其他信息。

在没有参数的情况下,将显示属于当前分支的请求。

使用--web,改为在 web 浏览器中,打开拉取请求。

Options

-c, --comments
查看 pull request 评论
-q, --jq <expression>
jq 表达式,过滤 JSON 输出
--json <fields>
JSON 输出特殊字段
-t, --template <string>
模板化输出
-w, --web
浏览器打开

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

See also

gh release

管理 GitHub 发布

Commands

Options

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

See also

gh release create

gh release create [<tag>] [<files>...]

为存储库创建新的 GitHub 版本(Release)。

新的版本,你可能要上传一系列的资源文件。要定义资源的显示标签,请在文件名之后,附加以#开头的文本。

如果匹配的 git tag 还不存在,那么将从默认分支的最新状态自动创建一个。使用--target来覆盖这个。要在发布后,在本地获取新 tag ,请执行以下操作git fetch --tags origin

要从带注释的 git tag 创建发行版,首先使用 git 在本地创建一个,然后将 tag 推送到 GitHub,然后运行此命令。

使用自动生成的 release 说明时,也会自动生成 release 标题,除非,明确传递了标题。通过使用 notes 参数,可以在自动生成的备注前,添加其他 release 说明。

Options

--discussion-category <string>
开始指定主题分类的讨论
-d, --draft
一个草稿版本
--generate-notes
自动生成,release 的 标题与笔记
-n, --notes <string>
Release 笔记
-F, --notes-file <file>
用文件,读笔记 (use "-" to read from standard input)
-p, --prerelease
预览版
--target <branch>
指定的分支或是完整的 commit SHA (default: main branch)
-t, --title <string>
Release 标题

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

Examples

# 交互式创建一个 release
$ gh release create

# 交互式创建一个 v1.2.3 release 
$ gh release create v1.2.3

# 非交互式创建一个 release
$ gh release create v1.2.3 --notes "bugfix release"

# 使用自动生成 Release 笔记
$ gh release create v1.2.3 --generate-notes

# 使用文件,给出 Release 笔记
$ gh release create v1.2.3 -F changelog.md

# 上传 dist 目录下,所有的 tgz,作为资源
$ gh release create v1.2.3 ./dist/*.tgz

# 上传一个资源,带标签
$ gh release create v1.2.3 '/path/to/asset.zip#My display label'

# 创建一个 release,并开启讨论
$ gh release create v1.2.3 --discussion-category "General"

See also

gh release delete

删除 release

gh release delete <tag> [flags]

Options

-y, --yes
跳过提示

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

See also

gh release download

gh release download [<tag>] [flags]

从 GitHub Release,下载资源。

如果没有显式的 tag 参数,资源将从项目的最新版本下载。在这种情况下,需要--pattern

Options

-A, --archive <format>
下载的格式 (zip or tar.gz)
-D, --dir <string>
下载的位置
-p, --pattern <stringArray>
只下载符合 glob 匹配模式的资源

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

Examples

# 下载 v1.2.3 的所有资源
$ gh release download v1.2.3

# 仅下载 Debian 包
$ gh release download --pattern '*.deb'

# 下载多文件
$ gh release download -p '*.deb' -p '*.rpm'

# 下载压缩文件
$ gh release download v1.2.3 --archive=zip

See also

gh release list

列出 Release

gh release list [flags]

Options

-L, --limit <int>
Maximum number of items to fetch

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

See also

gh release upload

gh release upload <tag> <files>... [flags]

将资产文件上载到 GitHub 版本。

要定义资源的显示标签,请在文件名后附加以#开头的文本。

Options

--clobber
覆盖同名资源

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

See also

gh release view

gh release view [<tag>] [flags]

查看有关 GitHub Release 的信息。

在没有显式标记名参数的情况下,将显示项目中的最新版本。

Options

-q, --jq <expression>
jq 表达式,过滤 JSON 输出
--json <fields>
JSON 输出特殊字段
-t, --template <string>
模板化输出
-w, --web
浏览器打开

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

See also

gh repo

使用 GitHub 存储库

Commands

Examples

$ gh repo create
$ gh repo clone cli/cli
$ gh repo view --web

See also

gh repo archive

gh repo archive [<repository>] [flags]

归档 GitHub 存储库。

在没有参数的情况下,归档当前存储库。

Options

-y, --confirm
跳过提示

See also

gh repo clone

gh repo clone <repository> [<directory>] [-- <gitflags>...]

本地克隆 GitHub 存储库。

如果省略OWNER/REPO存储库参数的OWNER/部分,则默认为验证用户的名称。

通过在--之后,给出其他git clone标志,来传递这些标志。

See also

gh repo create

gh repo create [<name>] [flags]

创建一个新的 GitHub 存储库。

要以交互方式创建存储库,请使用gh repo create,不带参数。

要以非交互方式创建远程存储库,请提供存储库名称和--public, --private--internal,通过--clone在本地克隆新存储库。

要从现有本地存储库创建远程存储库,请使用--source。默认情况下,远程存储库名称将是源目录的名称。通过--push将任何本地提交推送到新存储库。

Options

-c, --clone
Clone 新的存储库到当前目录
-d, --description <string>
存储库的描述
--disable-issues
禁用 issues
--disable-wiki
禁用 wiki
-g, --gitignore <string>
指定一个 gitignore 的模板
-h, --homepage <URL>
主页URL
--internal
内部可见
-l, --license <string>
指定开源的协议
--private
私有存储库
--public
公开存储库
--push
推送本地的 commits 到新的存储库
-r, --remote <string>
指定 remote 名称
-s, --source <string>
指定存储库的源代码路径e
-t, --team <name>
可以访问存储库的组织名字
-p, --template <repository>
让新的存储库,基于 一个模板存储库生成

Examples

# 交互式创建一个 存储库
gh repo create

# 创建一个新的远程存储库,并将它 clone 到本地
gh repo create my-project --public --clone

# 以本地目录为基础,创建一个新的远程存储库
gh repo create my-project --private --source=. --remote=upstream

See also

gh repo delete

gh repo delete [<repository>] [flags]

删除 GitHub 存储库。

在没有参数的情况下,删除当前存储库。或是,删除指定的存储库。

删除需要delete_repo范围的授权。要进行授权,请运行gh auth refresh -s delete_repo

Options

--confirm
直接通过提示

See also

gh repo edit

编辑存储库设置

gh repo edit [<repository>] [flags]

Options

--add-topic <strings>
添加 存储库 标签主题
--allow-forking
允许被 fork
--default-branch <name>
设置默认的分支
--delete-branch-on-merge
当 pull requests 被合并,删除 HEAD 分支
-d, --description <string>
存储库的描述
--enable-auto-merge
启动 auto-merge(自动合并) 功能
--enable-issues
启用 issues
--enable-merge-commit
可以用 merge commit,合并 PR
--enable-projects
启用 projects
--enable-rebase-merge
可用变基(rebase)的方式合并 PR
--enable-squash-merge
可用,将多个commit变为一个的方式,合并PR
--enable-wiki
启用 wiki
-h, --homepage <URL>
主页URL
--remove-topic <strings>
移除存储库的标签主题
--template
可将存储库当成,模板存储库
--visibility <string>
将存储库的可见性改为 {public,private,internal}

See also

gh repo fork

gh repo fork [<repository>] [-- <gitflags>...] [flags]

创建存储库的副本。

在没有参数的情况下,创建当前存储库的副本。否则,副本化指定的存储库。

默认情况下,新的副本地址会是你的origin,以及任何现有的远程 origin 都被重命名为upstream。要改变这种行为,您可以使用--remote-name,自己设一个名字。

其他git clone标志可以在--之后,传入。

Options

--clone
Clone the fork {true|false}
--org <string>
在一个组织内,创建副本
--remote
要添加远程(上级)存储库吗 {true|false}
--remote-name <string>
指定一个 fork's 新名

See also

gh repo list

列出用户或组织,拥有的存储库

gh repo list [<owner>] [flags]

Options

--archived
仅展示存档的存储库
--fork
仅展示副本存储库
-q, --jq <expression>
jq 表达式,过滤 JSON 输出
--json <fields>
JSON 输出特殊字段
-l, --language <string>
主编程语言的过滤
-L, --limit <int>
Maximum number of repositories to list
--no-archived
不要存档的存储库
--private
仅展示私有存储库
--public
仅展示公开的存储库
--source
仅展示非副本的存储库
-t, --template <string>
模板化输出
--topic <string>
标题主题的过滤

See also

gh repo rename

gh repo rename [<new-name>] [flags]

重命名 GitHub 存储库

默认情况下,这将重命名当前存储库;否则,将重命名指定的存储库。

Options

-y, --confirm
跳过提示,直接确定
-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

See also

gh repo sync

gh repo sync [<destination-repository>] [flags]

从源存储库**同步(sync)**到目标存储库。同步使用源存储库的 mian 分支,来更新目标存储库上的匹配分支,使它们相等。如果指定了--force标志,则强制同步两个分支。

如果没有参数,则选择本地存储库作为目标存储库。

默认情况下,源存储库是目标存储库的父存储库。可以使用--source更改

Options

-b, --branch <string>
同步的分支 (default: main branch)
--force
强制同步
-s, --source <string>
源存储库

Examples

# 同步
$ gh repo sync

# v1 分支同步
$ gh repo sync --branch v1

# 同步 owner/cli-fork
$ gh repo sync owner/cli-fork

# owner2/repo2 的内容,同步进 owner/repo
$ gh repo sync owner/repo --source owner2/repo2

See also

gh repo view

gh repo view [<repository>] [flags]

显示 GitHub 存储库的描述和 README。

如果没有参数,将显示当前目录的存储库。

使用--web,改为在 web 浏览器中,打开存储库。

使用--branch,查看存储库的特定分支。

Options

-b, --branch <string>
显示特定分支
-q, --jq <expression>
jq 表达式,过滤 JSON 输出
--json <fields>
JSON 输出特殊字段
-t, --template <string>
模板化输出
-w, --web
浏览器打开

See also

gh run

从 GitHub Actions列出、查阅和观察最近的工作流运行。

Commands

Options

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

See also

gh run cancel

取消工作流运行

gh run cancel [<run-id>]

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

See also

gh run download

gh run download [<run-id>] [flags]

下载 GitHub Actions工作流运行生成的工件。

每个工件的内容将根据工件名称,提取到单独的目录。如果只指定了一个工件,它将被提取到当前目录中。

Options

-D, --dir <string>
下载的目录
-n, --name <stringArray>
仅下载匹配文件名的工件

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

Examples

# 下载 run-id 的所有工件
$ gh run download <run-id>

# 下载 run-id 的 name 工件
$ gh run download <run-id> -n <name>

# 下载 run-id 的 name1, name2 工件
$ gh run download -n <name1> -n <name2>

# 交互式下载
$ gh run download

See also

gh run list

列出最近的工作流运行

gh run list [flags]

Options

-q, --jq <expression>
jq 表达式,过滤 JSON 输出
--json <fields>
JSON 输出特殊字段
-L, --limit <int>
Maximum number of runs to fetch
-t, --template <string>
模板化输出
-w, --workflow <string>
工作流的过滤

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

See also

gh run rerun

重新运行

gh run rerun [<run-id>]

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

See also

gh run view

查看工作流运行的摘要

gh run view [<run-id>] [flags]

Options

--exit-status
Exit with non-zero status if run failed
-j, --job <string>
查看一个特定的 job ID
-q, --jq <expression>
jq 表达式,过滤 JSON 输出
--json <fields>
JSON 输出特殊字段
--log
查看 完整的日志
--log-failed
查看运行失败的日志
-t, --template <string>
模板化输出
-v, --verbose
展示 job 步骤
-w, --web
浏览器打开

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

Examples

# 交互式查看
$ gh run view

# 查看特定的 run
$ gh run view 12345

# 查看特定的 job within a run
$ gh run view --job 456789

# 查看 job 的完整日志
$ gh run view --log --job 456789

# 若是 非零 返回,说明运行失败
$ gh run view 0451 --exit-status && echo "run pending or passed"

See also

gh run watch

观察 run,直到完成,并显示其进度

gh run watch <run-id> [flags]

Options

--exit-status
运行失败,退出代码 非零
-i, --interval <int>
刷新的时间间隙

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

Examples

# 终端一直观察,直到 run 完成
gh run watch

# 然后,试试运行其他命令
gh run watch && notify-send "run is done!"

See also

gh secret

机密(Secrets) 可以在存储库环境组织级别设置,以便在 GitHub Actions中使用。用户的机密可以设置为,还能在 GitHub 代码空间中使用。运行gh help secret set学习如何开始。

Commands

Options

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

See also

gh secret list

gh secret list [flags]

列出机密,有下面这几个级别:

  • repository(默认):可用于 存储库
  • environment:部署环境的操作
  • organization:组织内
  • user:代码空间

Options

-e, --env <string>
环境的机密
-o, --org <string>
组织的机密
-u, --user
用户的机密

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

See also

gh secret remove

gh secret remove <secret-name> [flags]

删除以下级别之一的机密:

  • repository(默认):可用于 存储库
  • environment:部署环境的操作
  • organization:组织内
  • user:代码空间

Options

-e, --env <string>
移除环境的机密
-o, --org <string>
移除组织的机密
-u, --user
移除用户的机密

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

See also

gh secret set

gh secret set <secret-name> [flags]

在以下级别之一设置机密的值:

  • repository(默认):可用于 存储库
  • environment:部署环境的操作
  • organization:组织内
  • user:代码空间

组织和用户机密可以选择性地限制,仅对特定存储库可用。

机密的值在发送到 GitHub 之前,在本地进行加密。

Options

-b, --body <string>
机密内容 (reads from standard input if not specified)
-e, --env <environment>
设置发布环境的机密
-f, --env-file <file>
加载 secret 名与值 (dotenv 格式文件)
--no-store
打印 encrypted, base64-encoded 值,而不是在 Github 上存储
-o, --org <organization>
设置组织的机密
-r, --repos <repositories>
能访问到一个组织或用户机密,列出这样的存储库
-u, --user
设置用户的机密
-v, --visibility <{all|private|selected}>
设置一个组织机密的可见性: {all|private|selected}

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

Examples

# 交互式,复制机密到当前存储库
$ gh secret set MYSECRET

# 读取一个环境变量的机密
$ gh secret set MYSECRET --body "$ENV_VALUE"

# 读取一个文件的机密
$ gh secret set MYSECRET < myfile.txt

# 设置发布环境的机密 
$ gh secret set MYSECRET --env myenvironment

# 设置 组织级别的机密,在公开与私有的存储库中,都可以看到
$ gh secret set MYSECRET --org myOrg --visibility all

# 设置 组织级别的机密,特定存储库可以看到
$ gh secret set MYSECRET --org myOrg --repos repo1,repo2,repo3

# 设置 用户级别的机密,到代码空间
$ gh secret set MYSECRET --user

# 用 ".env" 文件,设置多个机密
$ gh secret set -f .env

See also

gh ssh-key

管理在 GitHub 帐户中,注册的 SSH 密钥

Commands

See also

gh ssh-key add

向 GitHub 帐户,添加 SSH 密钥

gh ssh-key add [<key-file>] [flags]

Options

-t, --title <string>
密钥的 标题

See also

gh ssh-key list

列出 GitHub 帐户中的 SSH 密钥

gh ssh-key list

See also

gh workflow

在 GitHub Actions中列出、查看和运行工作流。

Commands

Options

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

See also

gh workflow disable

gh workflow disable [<workflow-id> | <workflow-name>]

禁用工作流,防止其在列出工作流时,运行或显示。

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

See also

gh workflow enable

gh workflow enable [<workflow-id> | <workflow-name>]

启用工作流,允许它在列出工作流时,运行和显示。

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

See also

gh workflow list

gh workflow list [flags]

列出工作流文件,默认情况下隐藏禁用的工作流。

Options

-a, --all
展示所有,即便是禁用的工作流
-L, --limit <int>
Maximum number of workflows to fetch

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

See also

gh workflow run

gh workflow run [<workflow-id> | <workflow-name>] [flags]

为给定工作流,创建 workflow_dispatch 事件。

此命令将触发 GitHub Actions,去运行给定的工作流文件。给定的工作流文件必须支持 workflow_dispatch上的(on)触发器,才能以这种方式运行。

如果工作流文件支持输入,可以通过以下几种方式指定输入:

  • 交互式的
  • 通过 -f-F
  • 作为 JSON,通过 STDIN 输入

Options

-F, --field <key=value>
key=value 模式的字符串参数,遵守 @ 语法
--json
通过 STDIN,读取 JSON 格式的工作流输入
-f, --raw-field <key=value>
key=value 模式的字符串参数
-r, --ref <string>
想要运行的 分支与 tag 下的工作流文件

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

Examples

# 交互式
$ gh workflow run

# 运行,默认分支下的 triage 工作流
$ gh workflow run triage.yml

# 运行,ref 分支下的 triage 工作流
$ gh workflow run triage.yml --ref my-branch

# 运行,默认分支下的 triage 工作流,带有参数
$ gh workflow run triage.yml -f name=scully -f greeting=hello

# 运行,默认分支下的 triage 工作流,带有参数(JSON 形式)
$ echo '{"name":"scully", "greeting":"hello"}' | gh workflow run triage.yml --json

See also

gh workflow view

查看工作流摘要

gh workflow view [<workflow-id> | <workflow-name> | <filename>] [flags]

Options

-r, --ref <string>
想要查看的 分支与 tag 下的工作流文件
-w, --web
浏览器打开
-y, --yaml
查看工作流的 yaml 文件

Options inherited from parent commands

-R, --repo <[HOST/]OWNER/REPO>
使用 [HOST/]OWNER/REPO 格式,选择另一存储库

Examples

# 交互式选择
$ gh workflow view

# 查看一个特定的工作流
$ gh workflow view 0451

See also