Skip to content

Commit 345e968

Browse files
committed
doc: add docs/github-cli.md
1 parent 72b973a commit 345e968

File tree

3 files changed

+270
-7
lines changed

3 files changed

+270
-7
lines changed

README.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ Quick Reference
159159
[Find](./docs/find.md)<!--rehype:style=background: rgb(16 185 129);-->
160160
[FFmpeg](./docs/ffmpeg.md)<!--rehype:style=background: rgb(0 193 9);&class=contributing-->
161161
[Gdb](./docs/gdb.md)<!--rehype:style=background: rgb(215 89 62);-->
162-
[Git](./docs/git.md)<!--rehype:style=background: rgb(215 89 62);&class=tag&data-lang=版本控制-->
163162
[Glances](./docs/glances.md)<!--rehype:style=background: rgb(16 185 129);-->
164163
[Grep](./docs/grep.md)<!--rehype:style=background: rgb(16 185 129);-->
165164
[Htop](./docs/htop.md)<!--rehype:style=background: rgb(16 185 129);-->
@@ -176,7 +175,6 @@ Quick Reference
176175
[Sed](./docs/sed.md)<!--rehype:style=background: rgb(16 185 129);-->
177176
[Systemd](./docs/systemd.md)<!--rehype:style=background: rgb(16 185 129);-->
178177
[SSH](./docs/ssh.md)<!--rehype:style=background: rgb(99 99 99);-->
179-
[Subversion (SVN)](./docs/subversion.md)<!--rehype:style=background: rgb(99 99 99);&class=tag&data-lang=版本控制-->
180178
[Screen](./docs/screen.md)<!--rehype:style=background: rgb(99 99 99);-->
181179
[Sysdig](./docs/sysdig.md)<!--rehype:style=background: rgb(1 171 199);-->
182180
[Tmux](./docs/tmux.md)<!--rehype:style=background: rgb(99 99 99);-->
@@ -189,14 +187,12 @@ Quick Reference
189187
## 工具
190188

191189
[ChatGPT](./docs/chatgpt.md)<!--rehype:style=background: rgb(74, 161, 129);&class=tag&data-lang=AI-->
192-
[Github Copilot](./docs/github-copilot.md)<!--rehype:style=background: rgb(125 45 220);&class=tag contributing&data-lang=AI&data-info=👆看看还缺点儿什么?-->
193190
[Emacs](./docs/emacs.md)<!--rehype:style=background: rgb(98 36 134);-->
194-
[Github](./docs/github.md)<!--rehype:style=background: rgb(36 41 47);-->
195191
[Linux Command](./docs/linux-command.md)<!--rehype:style=background: rgb(215 89 62);&class=tag&data-lang=命令速查-->
196192
[Mitmproxy](./docs/mitmproxy.md)<!--rehype:style=background: rgb(4 92 135);-->
197193
[nginx](./docs/nginx.md)<!--rehype:style=background: rgb(0 153 0);-->
198194
[RegEx 正则表达式](./docs/regex.md)<!--rehype:style=background: rgb(149 36 155);-->
199-
[Semver](./docs/semver.md)<!--rehype:style=background: rgb(106 111 141);-->
195+
[Semver 语义化版本](./docs/semver.md)<!--rehype:style=background: rgb(106 111 141);-->
200196
[Vim](./docs/vim.md)<!--rehype:style=background: rgb(9 150 8);-->
201197
[XPath](./docs/xpath.md)<!--rehype:style=background: rgb(91 163 230);-->
202198
<!--rehype:class=home-card-->
@@ -214,6 +210,17 @@ Quick Reference
214210
[SDKMAN](./docs/sdkman.md)<!--rehype:style=background: rgb(0 118 198);-->
215211
<!--rehype:class=home-card-->
216212

213+
## Git 版本控制
214+
215+
[Git](./docs/git.md)<!--rehype:style=background: rgb(215 89 62);&class=tag&data-lang=版本控制-->
216+
[Github](./docs/github.md)<!--rehype:style=background: rgb(36 41 47);-->
217+
[Github Copilot](./docs/github-copilot.md)<!--rehype:style=background: rgb(125 45 220);&class=tag contributing&data-lang=AI&data-info=👆看看还缺点儿什么?-->
218+
[Github CLI](./docs/github-cli.md)<!--rehype:style=background: rgb(36 41 47);-->
219+
[Github Actions](./docs/github-actions.md)<!--rehype:style=background: rgb(121 184 255);-->
220+
[Gitlab CI/CD](./docs/gitlab-ci.md)<!--rehype:style=background: rgb(226 67 41);&class=contributing-->
221+
[Subversion (SVN)](./docs/subversion.md)<!--rehype:style=background: rgb(99 99 99);&class=tag&data-lang=版本控制-->
222+
<!--rehype:class=home-card-->
223+
217224
## 数据库
218225

219226
[MySQL](./docs/mysql.md)<!--rehype:style=background: rgb(1 117 143);&class=tag&data-lang=SQL-->
@@ -256,8 +263,6 @@ Quick Reference
256263
[Aspect Ratio](./docs/aspect-ratio.md)<!--rehype:style=background: rgb(16 185 129);-->
257264
[ASCII Code](./docs/ascii-code.md)<!--rehype:style=background: rgb(16 185 129);-->
258265
[Symbol Code](./docs/symbol-code.md)<!--rehype:style=background: rgb(16 185 129);-->
259-
[Github Actions](./docs/github-actions.md)<!--rehype:style=background: rgb(121 184 255);-->
260-
[Gitlab CI/CD](./docs/gitlab-ci.md)<!--rehype:style=background: rgb(226 67 41);&class=contributing-->
261266
[Colors Named](./docs/colors-named.md)<!--rehype:style=background: rgb(16 185 129);&class=tag&data-lang=CSS-->
262267
[HTTP 状态码](./docs/http-status-code.md)<!--rehype:style=background: rgb(16 185 129);-->
263268
[HTML 字符实体](./docs/html-char.md)<!--rehype:style=background: rgb(16 185 129);&class=tag&data-lang=HTML-->

assets/github-cli.svg

Lines changed: 3 additions & 0 deletions
Loading

docs/github-cli.md

Lines changed: 255 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,255 @@
1+
Github CLI
2+
===
3+
4+
GitHub CLI 的快速参考,这是一个开源命令行工具,可在终端上启用 GitHub 功能。
5+
6+
入门
7+
---
8+
9+
### 安装
10+
<!--rehype:wrap-class=col-span-2-->
11+
12+
#### Windows
13+
<!--rehype:style=text-align: left;-->
14+
15+
| 工具 | 安装 | 升级 |
16+
| :----- | :--------------------------- | :--------------------------- |
17+
| WinGet | `winget install --id Github.cli` | `winget upgrade --id GitHub.cli` |
18+
| Scoop | `scoop install gh` | `scoop update gh` |
19+
| Choco | `choco install gh` | `choco upgrade gh` |
20+
<!--rehype:className=show-header left-align-->
21+
22+
#### Mac OS
23+
<!--rehype:style=text-align: left;-->
24+
25+
| 工具 | 安装 | 升级 |
26+
| :------- | :-------------------- | :------------------------------------------ |
27+
| Brew | `brew install gh` | `brew upgrade gh` |
28+
| MacPorts | `sudo port install gh`| `sudo port selfupdate && sudo port upgrade gh` |
29+
<!--rehype:className=show-header left-align-->
30+
31+
#### Linux
32+
<!--rehype:style=text-align: left;-->
33+
34+
请参见 [安装说明](https://github.com/cli/cli/blob/trunk/docs/install_linux.md) 以获取其他 Linux 发行版的信息。安装脚本:
35+
36+
```bash
37+
type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y)
38+
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
39+
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
40+
&& 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 \
41+
&& sudo apt update \
42+
&& sudo apt install gh -y
43+
```
44+
45+
### 基本用法
46+
47+
#### 帮助和文档
48+
<!--rehype:style=text-align: left;-->
49+
50+
显示命令选项:
51+
52+
| 命令 | 描述 |
53+
| :-------------------- | :------------------------------------------------------------------------------------------------------------- |
54+
| `gh help [command]` | 帮助提供应用程序中任何命令的帮助。只需键入 `gh help [命令路径]` 以获取完整详细信息。 |
55+
<!--rehype:className=style-list-arrow-->
56+
57+
#### 认证
58+
<!--rehype:style=text-align: left;-->
59+
60+
| 命令 | 描述 |
61+
| :-------------------- | :-------------------------------------------------------- |
62+
| `gh auth login` | 默认通过基于网页的浏览器进行身份验证 |
63+
| `gh auth logout` | 移除主机的身份验证配置 |
64+
| `gh auth refresh` | 扩展或修复存储凭据的权限范围 |
65+
| `gh auth setup-git` | 配置 Git 使用 GitHub CLI 作为凭据助手 |
66+
| `gh auth status` | 验证并显示有关您身份验证状态的信息 |
67+
| `gh auth token` | 打印 `gh` 配置使用的身份验证令牌 |
68+
<!--rehype:className=style-list-arrow-->
69+
70+
使用 GitHub 令牌:
71+
72+
```shell
73+
$ gh auth --with-token < token.txt
74+
```
75+
76+
### 仓库管理
77+
<!--rehype:wrap-class=col-span-2-->
78+
79+
#### 常规
80+
<!--rehype:style=text-align: left;-->
81+
82+
| 命令 | 描述 |
83+
| :------------------------ | :------------------------------------------ |
84+
| `gh repo create` | 创建一个新的 GitHub 仓库 |
85+
| `gh repo list [target]` | 列出某个用户或组织拥有的仓库 |
86+
<!--rehype:className=code-nowrap left-align-->
87+
88+
#### 目标
89+
<!--rehype:style=text-align: left;-->
90+
91+
| 命令 | 描述 |
92+
| :--------------------------- | :-------------------------------------------------------- |
93+
| `gh repo archive [repo]` | 存档一个 GitHub 仓库 |
94+
| `gh repo clone [dir]` | 在本地克隆一个 GitHub 仓库 |
95+
| `gh repo delete [repo]` | 删除一个 GitHub 仓库 |
96+
| `gh repo deploy-key` | 管理仓库中的部署密钥 |
97+
| `gh repo edit [repo]` | 编辑仓库设置 |
98+
| `gh repo fork [repo]` | 创建一个仓库的分叉 |
99+
| `gh repo rename [name]` | 重命名一个 GitHub 仓库 |
100+
| `gh repo set-default [repo]` | 设置默认的远程仓库 |
101+
| `gh repo sync [dest-repo]` | 从源仓库同步到目标仓库 |
102+
| `gh repo view [repo]` | 显示一个 GitHub 仓库的描述和 README |
103+
<!--rehype:className=code-nowrap left-align-->
104+
105+
### 问题
106+
107+
#### 搜索问题
108+
<!--rehype:style=text-align: left;-->
109+
110+
| 命令 | 描述 |
111+
| :------------------------- | :------------------------------- |
112+
| `gh search issues [query]` | 在 GitHub 上搜索问题 |
113+
114+
#### 示例
115+
<!--rehype:style=text-align: left;-->
116+
117+
搜索匹配关键词 "readme" 和 "typo" 的问题
118+
119+
```shell
120+
$ gh search issues readme typo
121+
```
122+
123+
搜索匹配短语 "broken feature" 的问题
124+
125+
```shell
126+
$ gh search issues "broken feature"
127+
```
128+
129+
搜索 cli 组织中的问题和拉取请求
130+
131+
```shell
132+
$ gh search issues --include-prs --owner=cli
133+
```
134+
135+
搜索分配给自己的开放问题
136+
137+
```shell
138+
$ gh search issues --assignee=@me --state=open
139+
```
140+
141+
搜索评论数超过 100 的问题
142+
143+
```shell
144+
$ gh search issues --comments=">100"
145+
```
146+
147+
搜索没有标签 "bug" 的问题
148+
149+
```shell
150+
$ gh search issues -- -label:bug
151+
```
152+
153+
### 拉取请求
154+
155+
**拉取请求操作**
156+
157+
| 命令 | 描述 |
158+
| :---------------- | :----------------------------------------- |
159+
| `gh pr create` | 在 GitHub 上创建拉取请求 |
160+
| `gh pr list` | 列出 GitHub 仓库中的拉取请求 |
161+
| `gh pr status` | 显示相关拉取请求的状态 |
162+
163+
**示例**
164+
165+
```shell
166+
$ gh pr status
167+
```
168+
169+
示例输出:
170+
171+
```
172+
Current branch
173+
#12 Remove the test feature [user:patch-2]
174+
- All checks failing - Review required
175+
176+
Created by you
177+
You have no open pull requests
178+
179+
Requesting a code review from you
180+
#13 Fix tests [branch]
181+
- 3/4 checks failing - Review required
182+
#15 New feature [branch]
183+
- Checks passing - Approved
184+
```
185+
186+
### GitHub Actions
187+
<!--rehype:wrap-class=col-span-2-->
188+
189+
**常规操作**
190+
191+
| 命令 | 描述 |
192+
| :----------------------- | :--------------------------------------------------------------------------- |
193+
| `gh workflow disable` | 禁用工作流,防止其运行或在列出工作流时显示 |
194+
| `gh workflow enable` | 启用工作流,允许其运行并在列出工作流时显示 |
195+
| `gh workflow list` | 列出工作流文件,默认隐藏禁用的工作流 |
196+
| `gh workflow run` | 为给定的工作流创建一个 `workflow_dispatch` 事件 |
197+
| `gh workflow view` | 查看工作流的摘要 |
198+
199+
**运行操作**
200+
201+
| 命令 | 描述 |
202+
| :----------------------- | :----------------------------------------------------------- |
203+
| `gh run cancel` | 取消一个工作流运行 |
204+
| `gh run delete` | 删除一个工作流运行 |
205+
| `gh run download` | 下载由 GitHub Actions 工作流运行生成的工件 |
206+
| `gh run list` | 列出最近的工作流运行 |
207+
| `gh run rerun` | 重新运行整个运行、仅失败的作业或运行中的特定作业 |
208+
| `gh run view` | 查看工作流运行的摘要 |
209+
| `gh run watch` | 观看一个运行直到其完成,显示其进度 |
210+
211+
### 别名
212+
213+
**常规别名设置**
214+
215+
| 命令 | 描述 |
216+
| :----------------------- | :--------------------------------------------------------- |
217+
| `gh alias delete` | 删除设置的别名 |
218+
| `gh alias import` | 从 YAML 文件的内容中导入别名 |
219+
| `gh alias list` | 打印出所有已配置的别名 |
220+
| `gh alias set` | 定义一个单词,当调用时会展开为完整的 `gh` 命令 |
221+
<!--rehype:className=style-list-->
222+
223+
### 发布
224+
225+
**常规操作**
226+
227+
| 命令 | 描述 |
228+
| :----------------------- | :----------------------------------------- |
229+
| `gh release create` | 为一个仓库创建新的 GitHub 发布 |
230+
| `gh release list` | 列出一个仓库中的发布 |
231+
<!--rehype:className=code-nowrap-->
232+
233+
**目标命令**
234+
235+
| 命令 | 描述 |
236+
| :------------------------ | :-------------------------------------- |
237+
| `gh release delete` | 删除一个发布 |
238+
| `gh release delete-asset` | 从一个发布中删除一个资产 |
239+
| `gh release download` | 从 GitHub 发布中下载资产 |
240+
| `gh release edit` | 编辑一个发布 |
241+
| `gh release upload` | 上传资产文件到一个 GitHub 发布 |
242+
| `gh release view` | 查看有关一个 GitHub 发布的信息 |
243+
<!--rehype:className=code-nowrap-->
244+
245+
### 配置
246+
247+
**目标设置**
248+
249+
| 命令 | 描述 |
250+
| :------------------------ | :--------------------------------------------- |
251+
| `gh config clear-cache` | 清除 CLI 缓存 |
252+
| `gh config get` | 打印给定配置键的值 |
253+
| `gh config list` | 打印配置键及其值的列表 |
254+
| `gh config set` | 用给定键的值更新配置 |
255+
<!--rehype:className=style-list-->

0 commit comments

Comments
 (0)