github-repo-management

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

GitHub 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
    ,
    git branch -D
    , deleting a repo, or overwriting remote history.
  • Default branch: Prefer
    main
    ; use
    master
    only when the repo already uses it.
  • 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":
  1. Create on GitHub (GitHub MCP only):
    • Use GitHub MCP
      create_repository
      (or equivalent) with
      name
      , optional
      description
      ,
      private
      (default from user intent).
  2. Set origin locally (if already in a git repo):
    bash
    git remote add origin https://github.com/<owner>/<repo>.git
    If
    origin
    exists and should point to the new repo, ask before changing it.
  3. If no local repo yet:
    bash
    git init
    git remote add origin https://github.com/<owner>/<repo>.git
  4. First push (after at least one commit):
    bash
    git push -u origin main
    Use
    main
    unless the GitHub repo was created with a different default branch.

当用户要求“创建仓库”或“创建GitHub仓库”时:
  1. 在GitHub上创建(仅通过GitHub MCP):
    • 使用GitHub MCP的
      create_repository
      (或等效功能),传入
      name
      、可选的
      description
      private
      (默认值根据用户意图确定)。
  2. 本地设置远程仓库(若已存在本地Git仓库):
    bash
    git remote add origin https://github.com/<owner>/<repo>.git
    origin
    已存在且需要指向新仓库,需先询问用户确认后再修改。
  3. 若本地无仓库
    bash
    git init
    git remote add origin https://github.com/<owner>/<repo>.git
  4. 首次推送(至少完成一次提交后):
    bash
    git push -u origin main
    除非GitHub仓库创建时指定了其他默认分支,否则默认使用
    main
    分支。

Push code

推送代码

When the user asks to "push code" or "push to GitHub":
  1. Ensure git repo exists: Run
    git status
    . If not a repo, ask whether to
    git init
    and set remote.
  2. Check remote:
    git remote -v
    . If no
    origin
    , ask for repo URL or create repo first.
  3. Commit cleanly:
    • git status
      to see changes.
    • Stage:
      git add <paths>
      or
      git add -A
      if user intends all changes.
    • 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.
  4. Push:
    git push origin <branch>
    . Default branch is
    main
    . If upstream not set:
    git push -u origin main
    .

当用户要求“推送代码”或“推送到GitHub”时:
  1. 确保Git仓库存在:运行
    git status
    。若当前目录不是Git仓库,询问用户是否要执行
    git init
    并设置远程仓库。
  2. 检查远程仓库:执行
    git remote -v
    。若没有
    origin
    ,询问用户提供仓库URL或先创建仓库。
  3. 规范提交
    • 执行
      git status
      查看变更。
    • 暂存文件:
      git add <paths>
      ;若用户希望暂存所有变更,使用
      git add -A
    • 遵循规范格式提交:
      git commit -m "type(scope): description"
    • 若存在未提交的变更且用户要求“推送”,需先提示用户提交变更;未经询问不得强制推送。
  4. 推送代码
    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":
  1. Identify repo: From
    git remote get-url origin
    (owner/repo) or user-provided owner/name.
  2. 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.

当用户要求“获取仓库信息”、“仓库详情”或“查看仓库”时:
  1. 确定仓库:通过
    git remote get-url origin
    获取(所有者/仓库名),或使用用户提供的所有者/仓库名。
  2. 通过GitHub MCP获取信息:使用MCP工具获取仓库详情(例如获取仓库信息、列出分支、列出PR)。汇总信息包括:名称、描述、默认分支、可见性、星标/复刻数(若可用)、克隆URL。

Branches

分支管理

  • Create branch:
    git checkout -b <branch-name>
    then push:
    git push -u origin <branch-name>
    .
  • Switch branch:
    git checkout <branch>
    or
    git switch <branch>
    .
  • Delete branch: Local
    git branch -d <branch>
    ; remote delete only after user confirmation:
    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 (
    head
    ,
    base
    default
    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
.
TypeUse for
feat
New feature
fix
Bug fix
docs
Documentation only
style
Formatting, no code change
refactor
Code change, no feature/fix
test
Adding or updating tests
chore
Build, tooling, deps
Examples:
  • feat(auth): add login endpoint
  • fix(api): correct date parsing
  • docs: update README setup steps

采用以下格式:
type(scope): short description
类型适用场景
feat
新增功能
fix
修复Bug
docs
仅修改文档
style
格式调整,无代码逻辑变更
refactor
代码重构,无新增功能或修复
test
添加或更新测试用例
chore
构建流程、工具或依赖项调整
示例:
  • feat(auth): add login endpoint
  • fix(api): correct date parsing
  • docs: 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
  • 所有提交需遵循规范格式。