1

I have forked my master code i.e zip/production and created a forked project i.e map/production on gitlab

Now I have made changes to my forked codebase and I want to maintain it that way:
I.e I dont want to touch the additional code present in separate files on my forked repo but I have also made updates on master code and want this to reflect the same on forked codebase without affecting the additional files and code present in map/production.

Its something like forked repo + additional code and the additional code should remain unaffected while bringing in changes from the master repo.

How to go about this?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
sunshine
  • 371
  • 1
  • 4
  • 18

1 Answers1

0

the addtional code should remain unaffected while bringing in changes from the master repo

That will be the case if you commit that additional code in its own branch.

That way, your local clone of your fork can add the original repo as a remote.

git remote add upstream /url/original/repo

You can configure master to pull from that remote:

git branch --set-upstream master upstream/master

That would make master push to upstream too, which is not possible, but you are not supposed to push master anyway: you should push only branches created for your modification, not existing branches that can change on the original upstream repo

At any time, you can refresh your master branch (with the content of the original repo)

git checkout master
git pull

And at any time, you can rebase your modifications on top of master:

git checkout myBranch git rebase master git push --force

(provided you did push myBranch at least once, with git push -u origin myBranch)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250