Skip to content

Commit 43fb9d7

Browse files
authored
Merge pull request #338 from sparrowren/docs/fix-contribution-sync
docs: fix fork synchronization instructions
2 parents 4ee6d2f + 56b3438 commit 43fb9d7

2 files changed

Lines changed: 38 additions & 8 deletions

File tree

‎README.md‎

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,33 @@ If you have any comments or suggestions about the documentation, please submit t
1616

1717
(1) Download the Asciidoc or Typora document editor.
1818

19-
(2) Check if the upstream repository has updates. If so, please sync to your own fork first:
19+
(2) Before contributing, sync your fork with the upstream repository. In your local clone of your fork, check the configured remotes:
2020

21+
```sh
22+
git remote -v
2123
```
22-
git remote
2324

25+
If `upstream` is missing, add it once with `git remote add upstream https://github.com/IvorySQL/ivorysql_docs.git`.
26+
27+
Commit or stash any local changes before switching branches. Choose the branch your PR will target, such as `master` or `v5.6`. Replace every `<target-branch>` below with the actual branch name:
28+
29+
```sh
2430
git fetch upstream
31+
git switch <target-branch>
32+
git merge --ff-only upstream/<target-branch>
33+
git push origin <target-branch>
34+
```
2535

26-
git merge upstream/main
36+
If the target branch does not exist locally, replace the `git switch <target-branch>` step above with the following command. This explicitly creates a local branch tracking your fork's branch, avoiding ambiguity when both remotes have a matching branch:
2737

28-
git push
38+
```sh
39+
git switch -c <target-branch> --track origin/<target-branch>
2940
```
3041

42+
Then continue with the merge and push steps above.
43+
44+
If the fast-forward merge fails because the branches have diverged, resolve the divergence before pushing.
45+
3146
(3) Familiarize yourself with the [Writing Guidelines](#writing-guidelines).
3247

3348
## Contribution Scope

‎README_zh.md‎

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,33 @@
1515

1616
(1)下载Asciidoc或者Typora文档编辑器。
1717

18-
(2)检查源仓库是否有更新,如果有更新请先更新并同步到自己的仓库。如有更新请参阅以下步骤,更新至最新版本:
18+
(2)贡献前,请先将自己的 fork 与上游仓库同步。在自己 fork 的本地克隆目录中,检查已配置的远程仓库:
1919

20+
```sh
21+
git remote -v
2022
```
21-
git remote
2223

24+
如果尚未配置 `upstream`,请先执行一次 `git remote add upstream https://github.com/IvorySQL/ivorysql_docs.git`。
25+
26+
切换分支前,请先提交本地修改,或使用 `git stash` 临时保存。请选择 PR 要提交到的目标分支,例如 `master` 或 `v5.6`。将下文所有 `<target-branch>` 替换为实际分支名:
27+
28+
```sh
2329
git fetch upstream
30+
git switch <target-branch>
31+
git merge --ff-only upstream/<target-branch>
32+
git push origin <target-branch>
33+
```
2434

25-
git merge upstream/main
35+
如果本地尚无目标分支,请将上述 `git switch <target-branch>` 步骤替换为以下命令。它会明确创建本地分支并跟踪自己 fork 的对应分支,避免两个远程仓库都有同名分支时产生歧义:
2636

27-
git push
37+
```sh
38+
git switch -c <target-branch> --track origin/<target-branch>
2839
```
2940

41+
然后继续执行上述合并和推送步骤。
42+
43+
如果分支历史已分叉,导致无法快进合并,请先处理分叉,再推送。
44+
3045
(3)熟悉[文档写作规范](#规范说明)
3146

3247
## 贡献范围

0 commit comments

Comments
 (0)