gh-reference
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGitHub CLI Reference (gh)
GitHub CLI 参考指南 (gh)
IMPORTANT: This skill is for READ-ONLY operations only. DO NOT execute any commands that create, modify, or delete resources.
重要提示:本技能仅用于执行只读操作,请勿执行任何创建、修改或删除资源的命令。
Repository Identification
仓库识别
Always be specific about which repository to use.
| Method | Command |
|---|---|
Use | |
| List remotes | |
Best Practice: Use explicitly instead of relying on the default repository to avoid ambiguity.
-R owner/repo请始终明确指定要使用的仓库。
| 方法 | 命令 |
|---|---|
使用 | |
| 列出远程仓库 | |
最佳实践:显式使用 参数,而非依赖默认仓库,避免出现歧义。
-R owner/repoIssues (Read-Only)
Issues (只读)
| Task | Command |
|---|---|
| List issues | |
| View issue | |
| View issue (web) | |
| Issue status | |
List options: , , ,
--state open|closed|all--label bug--assignee @me--limit 10| 任务 | 命令 |
|---|---|
| 列出Issue | |
| 查看Issue | |
| (网页端)查看Issue | |
| Issue状态 | |
列表筛选参数:、、、
--state open|closed|all--label bug--assignee @me--limit 10Pull Requests (Read-Only)
Pull Requests (只读)
| Task | Command |
|---|---|
| List PRs | |
| View PR | |
| View PR diff | |
| View PR checks | |
| PR status | |
List options: , , ,
--state open|closed|merged|all--label enhancement--draft--limit 10| 任务 | 命令 |
|---|---|
| 列出PR | |
| 查看PR | |
| 查看PR diff | |
| 查看PR检查项 | |
| PR状态 | |
列表筛选参数:、、、
--state open|closed|merged|all--label enhancement--draft--limit 10Repository (Read-Only)
仓库 (只读)
| Task | Command |
|---|---|
| View repo info | |
| View repo (web) | |
| List your repos | |
| List org repos | |
| 任务 | 命令 |
|---|---|
| 查看仓库信息 | |
| (网页端)查看仓库 | |
| 列出你的仓库 | |
| 列出组织仓库 | |
GitHub Actions - Workflow Runs (Read-Only)
GitHub Actions - 工作流运行 (只读)
| Task | Command |
|---|---|
| List runs | |
| View run | |
| View run log | |
| Watch run | |
List options: , , ,
--workflow <name>--branch <branch>--limit 10--status completed|failed|in_progress| 任务 | 命令 |
|---|---|
| 列出运行记录 | |
| 查看运行记录 | |
| 查看运行日志 | |
| 监控运行进度 | |
列表筛选参数:、、、
--workflow <name>--branch <branch>--limit 10--status completed|failed|in_progressGitHub Actions - Workflows (Read-Only)
GitHub Actions - 工作流 (只读)
| Task | Command |
|---|---|
| List workflows | |
| View workflow | `gh workflow view <name |
| View workflow YAML | `gh workflow view <name |
| 任务 | 命令 |
|---|---|
| 列出工作流 | |
| 查看工作流 | `gh workflow view <name |
| 查看工作流YAML配置 | `gh workflow view <name |
GitHub Actions - Cache (Read-Only)
GitHub Actions - 缓存 (只读)
| Task | Command |
|---|---|
| List caches | |
List options: , ,
--limit 10--sort size|created_at--order asc|desc| 任务 | 命令 |
|---|---|
| 列出缓存 | |
列表筛选参数:、、
--limit 10--sort size|created_at--order asc|descReleases (Read-Only)
发布 (只读)
| Task | Command |
|---|---|
| List releases | |
| View release | |
| View latest | |
| 任务 | 命令 |
|---|---|
| 列出发版记录 | |
| 查看发版信息 | |
| 查看最新发版 | |
Search (Read-Only)
搜索 (只读)
| Task | Command |
|---|---|
| Search repos | |
| Search issues | |
| Search PRs | |
| Search code | |
| Search commits | |
Examples:
bash
gh search repos "language:go stars:>1000"
gh search issues "is:open label:bug repo:cli/cli"
gh search code "function main" --language=go| 任务 | 命令 |
|---|---|
| 搜索仓库 | |
| 搜索Issue | |
| 搜索PR | |
| 搜索代码 | |
| 搜索提交 | |
示例:
bash
gh search repos "language:go stars:>1000"
gh search issues "is:open label:bug repo:cli/cli"
gh search code "function main" --language=goStatus (Read-Only)
状态 (只读)
| Task | Command |
|---|---|
| View status | |
| Org status | |
| Exclude repos | |
Shows assigned issues, PRs, review requests, mentions across your subscribed repositories.
| 任务 | 命令 |
|---|---|
| 查看状态 | |
| 组织状态 | |
| 排除指定仓库 | |
该命令会展示你已订阅仓库中分配给你的Issue、PR、评审请求、@提及等信息。
API (Read-Only GET Requests)
API (只读GET请求)
| Task | Command |
|---|---|
| GET endpoint | |
| With jq filter | |
| Paginate | |
Examples:
bash
gh api repos/owner/repo/issues --paginate
gh api repos/owner/repo/pulls -q '.[] | {number, title}'
gh api graphql -f query='query { viewer { login } }'| 任务 | 命令 |
|---|---|
| 调用GET接口 | |
| 搭配jq过滤 | |
| 分页获取结果 | |
示例:
bash
gh api repos/owner/repo/issues --paginate
gh api repos/owner/repo/pulls -q '.[] | {number, title}'
gh api graphql -f query='query { viewer { login } }'Common Output Options
常用输出选项
| Goal | Flag | Example |
|---|---|---|
| JSON output | | |
| JSON fields | | |
| Quiet (IDs only) | `--jq '.[] | .number'` |
| Web browser | | |
| 目标 | 标志 | 示例 |
|---|---|---|
| JSON格式输出 | | |
| 指定JSON返回字段 | | |
| 静默输出(仅返回ID) | `--jq '.[] | .number'` |
| 网页浏览器打开 | | |
Identifying the Current Repository
识别当前仓库
Before running commands, determine the repository:
bash
undefined运行命令前,请先确认当前操作的仓库:
bash
undefinedFrom git remote
从git远程仓库获取
git remote -v
git remote -v
From jj (if using Jujutsu)
从jj获取(如果使用Jujutsu)
jj git remote list
**Always use explicit `-R owner/repo`** to ensure you're querying the correct repository.jj git remote list
**请始终显式指定 `-R owner/repo` 参数**,确保你查询的是正确的仓库。