0

My goal is to clone or fork a project to make modifications to it, but I would like to keep benefitting from updates made to the original (be either from the master branch or others) and merge them to my own private repo.

Making a fork forces the repo to be public, something that is not an option

What is the best course of action to follow? What about merging updates from other forks of the same project?

Right now what I have done is download the source code and set up a new repo with it. This of course means that anytime i want to apply updates I have to download the updated files and overwrite my files with those, which is not ideal because if i modify my the same files in my repo i have to make the same modifications to every file I want to update. There must be a way to do this, but after hours of googling I havent found what I'm looking for

Antonio Petricca
  • 8,891
  • 5
  • 36
  • 74
ghylander
  • 136
  • 8

1 Answers1

1

My approach is the following (for forked repositories):

git remote add upstream {{upstream-url}} # Point to the original repo

git merge --no-commit upstream # Merge changes from upstream with no auto commit

# Review changes...

git commit # Commit changes (no comment required)
Antonio Petricca
  • 8,891
  • 5
  • 36
  • 74
  • what about 'merging' files together? say, i have a file modified from the original project. A commit to the project updates that file. Merging the commits would overwrite my file, but what i want is to keep both my changes and the origin changes (given they do not cause conflict) – ghylander Sep 07 '21 at 07:57
  • Git does not merge anything if there are some local changes. In that case you have to stash or commit them in order to continue with merging. – Antonio Petricca Sep 07 '21 at 08:00
  • ah of course, how could i forget about that :facepalm: – ghylander Sep 07 '21 at 08:01
  • Let me know if my solution worked. Regards – Antonio Petricca Sep 07 '21 at 08:04
  • 1
    had some trouble but i finally managed to get it working exactly as i wanted. I had to use the --allow-unrelated-histories to make it work – ghylander Sep 10 '21 at 13:36