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

廉价感情. 提交于 2019-12-06 15:49:41

问题


Suppose i forked a repo from Github now iam having 2 project sources one is the main master branch in owner repository and other is my master branch in my fork.

Now i got a problem like this.

Suppose in my project there is a file Readme with the code like this

Topics to completed

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

So i have forked my repo and after completion of each topic i would mark a X and save the file in my local repo like this.

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

Upto to here no problem was there,but real problem was during the completion of two topics the original master have few more topics to the Readme file and it looks like this now.

Topics to completed

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

So now i wanted to update the links and this commands will not use because my previous markings will be lost when i execute git fetch upstream and git pull upstream master.

Version of Readme file i want in my local repo is in this format.

Topics to completed

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

Please help.


回答1:


Beside the fact you should make any evolution in a dedicated feature branch, you should not pull directly (that merges upstream/master into your master)

You should pull --rebase (which replays your local commits on top of the updated upstream/master), and then git push --force back to your fork.

You should get back your markers after re-applying your commits in the updated README.



来源:https://stackoverflow.com/questions/39928309/how-to-make-fork-changes-reflect-with-the-master-when-updated

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!