docs(skills): 添加 Fork-based PR 协作流程规范 #6

Merged
wbtiger merged 2 commits from docs/fork-based-pr-workflow-gitlink into master 2026-04-18 17:13:56 +08:00
2 changed files with 69 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即使有 admin 权限也不行。除非用户明确要求「直接 push」。**
### 在自己仓库直接提 PR仅限用户明确要求时
```bash
# 1. 创建分支

View File

@ -205,6 +205,47 @@ 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直接污染主仓库
- ❌ 即使有写权限也不要直接往主仓库推分支
### 例外
- 用户明确要求「直接 push」或「不用 Fork」时可以直接推分支提 PR
- 除此之外,即使是仓库 admin/owner 也应走 Fork 流程
## ⛔ 工具使用边界
**GitLink 平台的操作必须通过 `gitlink-cli` 完成,不能用其他平台的 CLI 替代。**