更新时如何使分支更改反映在主服务器上?

How to make fork changes reflect with the master when updated?

假设我从 Github 分叉了一个 repo,现在我有 2 个项目源,一个是所有者存储库中的主要主分支,另一个是我分叉中的主分支。

现在我遇到了这样的问题。

假设在我的项目中有一个 Readme 文件,其代码如下

待完成的主题

- [ ] Introduction
- [ ] [The Evolution of topic name(video)]
- [ ] [Background story]
- [ ] [Improvements]
- [ ] [Problems]
- [ ] [COnclusion]

所以我分叉了我的存储库,在完成每个主题后我会标记一个 X 并将文件像这样保存在我的本地存储库中。

- [X] Introduction
- [X] [The Evolution of topic name(video)]
- [ ] [Background story]
- [ ] [Improvements]
- [ ] [Problems]
- [ ] [COnclusion]

到目前为止没有问题,但真正的问题是在完成两个主题的过程中,原主人对自述文件的主题很少,现在看起来像这样。

待完成的主题

- [ ] Introduction
- [ ] [The Evolution of topic name(video)]
- [ ] [Background story]
- [ ] [New topics -1]
- [ ] [New topics -2]
- [ ] [New topics -3]
- [ ] [Improvements]
- [ ] [Problems]
- [ ] [COnclusion]

所以现在我想更新链接,这个命令将不会使用,因为当我执行 git fetch upstreamgit pull upstream master.

时,我以前的标记将会丢失

我想要在本地存储库中使用的自述文件版本是这种格式。

待完成的主题

- [X] Introduction
- [X] [The Evolution of topic name(video)]
- [ ] [Background story]
- [ ] [New topics -1]
- [ ] [New topics -2]
- [ ] [New topics -3]
- [ ] [Improvements]
- [ ] [Problems]
- [ ] [COnclusion]

请帮忙。

除了你应该在 dedicated feature branch 中进行任何进化之外,你不应该直接拉动(将 upstream/master 合并到你的 master

你应该pull --rebase(它在更新的 upstream/master 之上重播你的本地提交),然后 git push --force 回到你的分支。

在更新的 README 中重新应用您的提交后,您应该取回您的标记。