Skip to content
Advertisement

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

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.

Advertisement

Answer

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.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement