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

1

1 Answer 1

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)
5
  • 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
    Commented Sep 7, 2021 at 7: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. Commented Sep 7, 2021 at 8:00
  • ah of course, how could i forget about that :facepalm:
    – ghylander
    Commented Sep 7, 2021 at 8:01
  • Let me know if my solution worked. Regards Commented Sep 7, 2021 at 8: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
    Commented Sep 10, 2021 at 13:36

Not the answer you're looking for? Browse other questions tagged or ask your own question.