github-repo-management
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGitHub Repository Management
GitHub仓库管理
Rules
规则
- Secrets: Do not echo, log, or include any token or secret in output, commands, or file contents. GitHub MCP handles auth.
- Destructive actions: Ask for confirmation before ,
git push --force, deleting a repo, or overwriting remote history.git branch -D - Default branch: Prefer ; use
mainonly when the repo already uses it.master - Commits: Use Conventional Commits (e.g. ,
feat:,fix:).docs:
- 保密要求:不得在输出、命令或文件内容中回显、记录或包含任何令牌或机密信息。GitHub MCP负责处理身份验证。
- 破坏性操作:在执行、
git push --force、删除仓库或覆盖远程历史记录前,需先请求用户确认。git branch -D - 默认分支:优先使用;仅当仓库已使用
main时才采用该分支名。master - 提交信息:遵循Conventional Commits规范(例如、
feat:、fix:)。docs:
Capabilities
功能
- Run git commands locally (init, add, commit, push, branch, checkout, etc.).
- Operate on GitHub via GitHub MCP only: create repos, get repo info, list/create/merge PRs, manage branches. Do not use REST API or GITHUB_TOKEN directly.
- 本地运行Git命令(init、add、commit、push、branch、checkout等)。
- 仅通过GitHub MCP操作GitHub:创建仓库、获取仓库信息、列出/创建/合并PR、管理分支。不得直接使用REST API或GITHUB_TOKEN。
Create a repo
创建仓库
When the user asks to "create a repo" or "create a GitHub repository":
-
Create on GitHub (GitHub MCP only):
- Use GitHub MCP (or equivalent) with
create_repository, optionalname,description(default from user intent).private
- Use GitHub MCP
-
Set origin locally (if already in a git repo):bash
git remote add origin https://github.com/<owner>/<repo>.gitIfexists and should point to the new repo, ask before changing it.origin -
If no local repo yet:bash
git init git remote add origin https://github.com/<owner>/<repo>.git -
First push (after at least one commit):bash
git push -u origin mainUseunless the GitHub repo was created with a different default branch.main
当用户要求“创建仓库”或“创建GitHub仓库”时:
-
在GitHub上创建(仅通过GitHub MCP):
- 使用GitHub MCP的(或等效功能),传入
create_repository、可选的name、description(默认值根据用户意图确定)。private
- 使用GitHub MCP的
-
本地设置远程仓库(若已存在本地Git仓库):bash
git remote add origin https://github.com/<owner>/<repo>.git若已存在且需要指向新仓库,需先询问用户确认后再修改。origin -
若本地无仓库:bash
git init git remote add origin https://github.com/<owner>/<repo>.git -
首次推送(至少完成一次提交后):bash
git push -u origin main除非GitHub仓库创建时指定了其他默认分支,否则默认使用分支。main
Push code
推送代码
When the user asks to "push code" or "push to GitHub":
- Ensure git repo exists: Run . If not a repo, ask whether to
git statusand set remote.git init - Check remote: . If no
git remote -v, ask for repo URL or create repo first.origin - Commit cleanly:
- to see changes.
git status - Stage: or
git add <paths>if user intends all changes.git add -A - Commit with a conventional message: .
git commit -m "type(scope): description" - If there are uncommitted changes and user said "push", offer to commit first; do not force-push without asking.
- Push: . Default branch is
git push origin <branch>. If upstream not set:main.git push -u origin main
当用户要求“推送代码”或“推送到GitHub”时:
- 确保Git仓库存在:运行。若当前目录不是Git仓库,询问用户是否要执行
git status并设置远程仓库。git init - 检查远程仓库:执行。若没有
git remote -v,询问用户提供仓库URL或先创建仓库。origin - 规范提交:
- 执行查看变更。
git status - 暂存文件:;若用户希望暂存所有变更,使用
git add <paths>。git add -A - 遵循规范格式提交:。
git commit -m "type(scope): description" - 若存在未提交的变更且用户要求“推送”,需先提示用户提交变更;未经询问不得强制推送。
- 执行
- 推送代码:。默认分支为
git push origin <branch>。若未设置上游分支,使用main。git push -u origin main
Get repo info
获取仓库信息
When the user asks to "get repo info", "repo details", or "show repository":
- Identify repo: From (owner/repo) or user-provided owner/name.
git remote get-url origin - Fetch via GitHub MCP: Use MCP tools to get repository details (e.g. get repo, list branches, list PRs). Summarize: name, description, default branch, visibility, stars/forks if available, clone URL.
当用户要求“获取仓库信息”、“仓库详情”或“查看仓库”时:
- 确定仓库:通过获取(所有者/仓库名),或使用用户提供的所有者/仓库名。
git remote get-url origin - 通过GitHub MCP获取信息:使用MCP工具获取仓库详情(例如获取仓库信息、列出分支、列出PR)。汇总信息包括:名称、描述、默认分支、可见性、星标/复刻数(若可用)、克隆URL。
Branches
分支管理
- Create branch: then push:
git checkout -b <branch-name>.git push -u origin <branch-name> - Switch branch: or
git checkout <branch>.git switch <branch> - Delete branch: Local ; remote delete only after user confirmation:
git branch -d <branch>.git push origin --delete <branch>
- 创建分支:,然后推送:
git checkout -b <branch-name>。git push -u origin <branch-name> - 切换分支:或
git checkout <branch>。git switch <branch> - 删除分支:本地删除使用;远程分支删除需先获得用户确认,命令为
git branch -d <branch>。git push origin --delete <branch>
Pull requests
Pull Request(PR)管理
- Open PR: Use GitHub MCP to create a pull request (,
headdefaultbase,main,title).body - List PRs: Use GitHub MCP to list PRs; summarize by number, title, state, author.
- Merge: Use GitHub MCP to merge; confirm with user before merging.
- 发起PR:使用GitHub MCP创建Pull Request(需指定、默认
head为base、main、title)。body - 列出PR:使用GitHub MCP列出PR;汇总信息包括PR编号、标题、状态、作者。
- 合并PR:使用GitHub MCP合并PR;合并前需获得用户确认。
Conventional commit messages
规范提交信息格式
Use this format: .
type(scope): short description| Type | Use for |
|---|---|
| New feature |
| Bug fix |
| Documentation only |
| Formatting, no code change |
| Code change, no feature/fix |
| Adding or updating tests |
| Build, tooling, deps |
Examples:
feat(auth): add login endpointfix(api): correct date parsingdocs: update README setup steps
采用以下格式:。
type(scope): short description| 类型 | 适用场景 |
|---|---|
| 新增功能 |
| 修复Bug |
| 仅修改文档 |
| 格式调整,无代码逻辑变更 |
| 代码重构,无新增功能或修复 |
| 添加或更新测试用例 |
| 构建流程、工具或依赖项调整 |
示例:
feat(auth): add login endpointfix(api): correct date parsingdocs: update README setup steps
Summary checklist
检查清单
- GitHub operations: GitHub MCP only (no REST API, no GITHUB_TOKEN in commands).
- Confirm before force push, branch delete, or repo delete.
- Default branch: .
main - All commits: conventional style.
- GitHub操作:仅使用GitHub MCP(不得使用REST API,命令中不得包含GITHUB_TOKEN)。
- 执行强制推送、删除分支或删除仓库前需确认。
- 默认分支使用。
main - 所有提交需遵循规范格式。