r/github • • 1d ago

Question Forking a project.

I've never forked anything before so I'm unsure what's the right procedure. I want to take an open source project and create a derivative work. The code is under GPL, so I have the right to modify it and redistribute it provided I keep the source open, right?

The question is should I fork the project or just clone it? I'm not really interested in making pull requests and I don't know they even make sense in the first place as I'm going to change their core api so they don't gain much from merging my fork.

I have a ton of questions. If I fork I create a kinda link to the upstream project. Can they see my fork? Having a fork makes it easier to sync the project with them, and that's the only benefit as I see it.

What if I delete parts of the project can I still sync with the upstream branch? Will I get back the deleted parts or trigger an error? I'm only interested in their core library, the satellite libraries are no interest to me.

I will rename the project and wrap all their classes in a HAL layer so I can keep my api independent of their unstable one. If I keep the project local is there still some way of pulling down changes from upstream and merging them with my local branch?

8 Upvotes

7 comments sorted by

10

u/keelanstuart 1d ago

Fork on GitHub. Clone your fork.

4

u/AllanTaylor314 1d ago

GPL only requires that you distribute the source if you distribute the program/binary. If you only use it yourself, there's no distribution requirement.  What's your plan for this?

You can set multiple remotes locally (e.g. origin for your repo and upstream for theirs) to pull in their changes, though that'll work best if you keep the same repo layout.

Forking will appear in their fork network. You'll have a banner at the top with X ahead Y behind upstream. Under the name, it will say fork from XYZ. You won't be able to set it to private

If you make a separate non-fork repo, you won't be able to open PRs into upstream. That only works from a fork

Docs

4

u/Soggy_Writing_3912 1d ago

exactly.

If you want to be able to bring in new updates in the future from the upstream, but at the same time, you don't want your fork to show up in github as a fork, you can simply clone their repo onto your local, change the remote url, and push to a new repo under your userid. This affectively breaks Github's "view" of the fork.

Then, in case you also want to bring in new changes from their repo, you need to do 2 things:

  1. Ensure the original history (at least till this point of time) is preserved so that there's a common ancestral commit from the point of the "branch-off"
  2. Add a new remote (I usually call it upstream) and then pull/rebase/merge from upstream for new changes. Only push to your remote and not the upstream one (which, if you are not part of the team, you won't have access to anyways).

3

u/SlowPlan8945 19h ago

Yes—under GPL, you can freely modify, rename, and redistribute the code as long as your derivative work stays licensed under the GPL and you make the source code available when distributing binaries.

2

u/Bali10050 1d ago

Not every fork needs to be merged.

Can they see my fork?

Yes they can

What if I delete parts of the project can I still sync with the upstream branch? Will I get back the deleted parts or trigger an error? I'm only interested in their core library, the satellite libraries are no interest to me.

Depends.

I will rename the project and wrap all their classes in a HAL layer so I can keep my api independent of their unstable one. If I keep the project local is there still some way of pulling down changes from upstream and merging them with my local branch?

You can just do things on your machine, you don't need to upload to github

0

u/rhutroh 1d ago

you are overthinking this.

2

u/Soggy_Writing_3912 1d ago

no - not necessarily