docs(skills): add Fork-based PR workflow guidelines

- gitlink-shared: add 'PR Collaboration Workflow' section with Fork flow,
  correct/incorrect examples, and self-owned repo exception
- gitlink-pr: replace single-path PR creation with two sections:
  1. Fork flow for contributing to others' repos (mandatory)
  2. Direct branch flow for self-owned repos (allowed)

Ensures AI agents follow standard open-source collaboration practices
instead of pushing branches directly to upstream repositories.
This commit is contained in:
wbtiger 2026-04-18 16:56:55 +08:00
parent c2cc921908
commit 445e548f49
2 changed files with 68 additions and 1 deletions

View File

@ -52,7 +52,34 @@ gitlink-cli pr +files --id 14200
## 创建 PR 的完整流程
PR 创建需要源分支有实际代码变更。完整流程:
### 向他人仓库提 PRFork 流程,必须遵守)
```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. 创建分支

View File

@ -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 替代。**