gh
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGitHub CLI (gh)
GitHub CLI (gh)
Overview
概述
Use for authenticated GitHub operations from the terminal. Prefer explicit, idempotent commands and report URLs back to the user.
gh使用在终端中执行经过身份验证的GitHub操作。优先使用显式、幂等的命令,并将操作生成的URL返回给用户。
ghQuick checks
快速检查
- Auth status:
bash
gh auth status- Current repo context:
bash
gh repo view --json nameWithOwner,url,defaultBranchRef- 认证状态:
bash
gh auth status- 当前仓库上下文:
bash
gh repo view --json nameWithOwner,url,defaultBranchRefCore workflows
核心工作流
Repo create (private by default)
创建仓库(默认私有)
bash
gh repo create OWNER/NAME --private --confirm --description "..."If running inside a local repo, use .
--source . --remote origin --pushbash
gh repo create OWNER/NAME --private --confirm --description "..."如果在本地仓库目录内执行命令,请使用参数。
--source . --remote origin --pushClone / fork
克隆 / 分叉
bash
gh repo clone OWNER/NAMEbash
gh repo fork OWNER/NAME --clonebash
gh repo clone OWNER/NAMEbash
gh repo fork OWNER/NAME --cloneIssues
Issues
- List:
bash
gh issue list --limit 20- Create:
bash
gh issue create --title "..." --body "..."- Comment:
bash
gh issue comment <num> --body "..."- 列出:
bash
gh issue list --limit 20- 创建:
bash
gh issue create --title "..." --body "..."- 评论:
bash
gh issue comment <num> --body "..."Pull requests
Pull requests
- Create from current branch:
bash
gh pr create --title "..." --body "..."- List:
bash
gh pr list --limit 20- View:
bash
gh pr view <num> --web- Merge (use explicit method):
bash
gh pr merge <num> --merge- 从当前分支创建:
bash
gh pr create --title "..." --body "..."- 列出:
bash
gh pr list --limit 20- 查看:
bash
gh pr view <num> --web- 合并(使用显式合并方式):
bash
gh pr merge <num> --mergeReleases
版本发布
bash
gh release create vX.Y.Z --title "vX.Y.Z" --notes "..."bash
gh release create vX.Y.Z --title "vX.Y.Z" --notes "..."Safety notes
安全注意事项
- Confirm the target repo/owner before destructive actions (delete, force push).
- For private repos, ensure is set on create.
--private - Prefer to avoid interactive prompts in automation.
--confirm
- 执行破坏性操作(删除、强制推送)前,请确认目标仓库/所有者是否正确。
- 创建私有仓库时,请确保设置了参数。
--private - 在自动化场景中优先使用参数避免交互式提示。
--confirm