From abcab5a516d5efaf04b1238a6b64a8c8a53973f8 Mon Sep 17 00:00:00 2001 From: wbtiger <28288271@qq.com> Date: Sat, 18 Apr 2026 16:57:55 +0800 Subject: [PATCH 1/2] =?UTF-8?q?docs(skills):=20=E6=B7=BB=E5=8A=A0=20Fork-b?= =?UTF-8?q?ased=20PR=20=E5=8D=8F=E4=BD=9C=E6=B5=81=E7=A8=8B=E8=A7=84?= =?UTF-8?q?=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - gitlink-shared: 新增 PR 协作流程章节(Fork 流程 + 错误做法 + 例外) - gitlink-pr: 区分「向他人仓库提 PR」和「在自己仓库提 PR」两种场景 确保 AI Agent 遵循标准开源协作规范,不直接往他人主仓库推分支 --- skills/gitlink-pr/SKILL.md | 29 +++++++++++++++++++++++- skills/gitlink-shared/SKILL.md | 40 ++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 1 deletion(-) diff --git a/skills/gitlink-pr/SKILL.md b/skills/gitlink-pr/SKILL.md index ecfcdb2..25b1138 100644 --- a/skills/gitlink-pr/SKILL.md +++ b/skills/gitlink-pr/SKILL.md @@ -52,7 +52,34 @@ gitlink-cli pr +files --id 14200 ## 创建 PR 的完整流程 -PR 创建需要源分支有实际代码变更。完整流程: +### 向他人仓库提 PR(Fork 流程,必须遵守) + +```bash +# 1. Fork 目标仓库 +gitlink-cli repo +fork --owner TargetOrg --repo target-repo + +# 2. Clone 自己的 Fork +git clone https://www.gitlink.org.cn/MyUser/target-repo.git +cd target-repo +git remote add upstream https://www.gitlink.org.cn/TargetOrg/target-repo.git + +# 3. 创建分支、修改、提交 +git checkout -b fix/my-change +# ... 修改文件 ... +git add -A && git commit -m "fix: my change" + +# 4. Push 到自己的 Fork(不是 upstream) +git push origin fix/my-change + +# 5. 从 Fork 向主仓库提 PR +gitlink-cli pr +create --owner TargetOrg --repo target-repo \ + --head MyUser:fix/my-change --base master \ + --title "fix: my change" +``` + +> ⛔ **禁止直接往他人的主仓库推分支再提 PR,即使有写权限也不行。** + +### 在自己仓库提 PR(可直接推分支) ```bash # 1. 创建分支 diff --git a/skills/gitlink-shared/SKILL.md b/skills/gitlink-shared/SKILL.md index d43f7e9..ebea574 100644 --- a/skills/gitlink-shared/SKILL.md +++ b/skills/gitlink-shared/SKILL.md @@ -205,6 +205,46 @@ gitlink-cli repo +push - **写入/删除操作前必须确认用户意图** - 危险操作(删除仓库、删除分支等)需二次确认 +## ⚠️ PR 协作流程(Fork-based) + +向他人仓库(非自己拥有的仓库)提交 PR 时,**必须走 Fork 流程**,禁止直接往主仓库推分支。 + +### 正确流程 + +```bash +# 1. Fork 目标仓库(在 GitLink 网页或 CLI 操作) +gitlink-cli repo +fork --owner TargetOrg --repo target-repo + +# 2. Clone 自己的 Fork +git clone https://www.gitlink.org.cn/MyUser/target-repo.git +cd target-repo + +# 3. 添加 upstream remote +git remote add upstream https://www.gitlink.org.cn/TargetOrg/target-repo.git + +# 4. 创建分支、修改、提交 +git checkout -b fix/my-change +# ... 修改文件 ... +git add -A && git commit -m "fix: my change" + +# 5. Push 到自己的 Fork(不是 upstream) +git push origin fix/my-change + +# 6. 从 Fork 向主仓库提 PR +gitlink-cli pr +create --owner TargetOrg --repo target-repo \ + --head MyUser:fix/my-change --base master \ + --title "fix: my change" +``` + +### 错误做法 + +- ❌ `git clone` 主仓库 → 建分支 → `git push origin` → 提 PR(直接污染主仓库) +- ❌ 即使有写权限也不要直接往主仓库推分支 + +### 例外 + +- 自己拥有的仓库可以直接推分支提 PR(不需要 Fork 自己的仓库) + ## ⛔ 工具使用边界 **GitLink 平台的操作必须通过 `gitlink-cli` 完成,不能用其他平台的 CLI 替代。** -- 2.34.1 From b0e9fa99e38e65da73d1f6ba0255ba10bc1b4e46 Mon Sep 17 00:00:00 2001 From: wbtiger <28288271@qq.com> Date: Sat, 18 Apr 2026 17:07:48 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20admin/owner=20=E4=B9=9F=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E8=B5=B0=20Fork=EF=BC=8C=E9=99=A4=E9=9D=9E=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=98=8E=E7=A1=AE=E8=A6=81=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- skills/gitlink-pr/SKILL.md | 4 ++-- skills/gitlink-shared/SKILL.md | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/skills/gitlink-pr/SKILL.md b/skills/gitlink-pr/SKILL.md index 25b1138..ff3e34b 100644 --- a/skills/gitlink-pr/SKILL.md +++ b/skills/gitlink-pr/SKILL.md @@ -77,9 +77,9 @@ gitlink-cli pr +create --owner TargetOrg --repo target-repo \ --title "fix: my change" ``` -> ⛔ **禁止直接往他人的主仓库推分支再提 PR,即使有写权限也不行。** +> ⛔ **禁止直接往主仓库推分支再提 PR,即使有 admin 权限也不行。除非用户明确要求「直接 push」。** -### 在自己仓库提 PR(可直接推分支) +### 在自己仓库直接提 PR(仅限用户明确要求时) ```bash # 1. 创建分支 diff --git a/skills/gitlink-shared/SKILL.md b/skills/gitlink-shared/SKILL.md index ebea574..39f012d 100644 --- a/skills/gitlink-shared/SKILL.md +++ b/skills/gitlink-shared/SKILL.md @@ -243,7 +243,8 @@ gitlink-cli pr +create --owner TargetOrg --repo target-repo \ ### 例外 -- 自己拥有的仓库可以直接推分支提 PR(不需要 Fork 自己的仓库) +- 用户明确要求「直接 push」或「不用 Fork」时,可以直接推分支提 PR +- 除此之外,即使是仓库 admin/owner 也应走 Fork 流程 ## ⛔ 工具使用边界 -- 2.34.1