How to "re-link" my fork to its "grandparent" repo instead of "parent" fork?

Sorry I don’t know the correct terminology: Suppose there is a git repository by Alice, and Bob made a fork of it. Next, I made a fork of Bob’s fork. So the fork “lineage” is:

Alice -> Bob's fork -> my fork

Is there a way to change the plumbing so that my fork directly tracks Alice’s original repo instead of Bob’s fork? Like this:

Alice -> my fork

This way, I can choose to incorporate changes in Alice’s repo directly into my fork instead of waiting for Bob to incorporate them into his.

I know forking is more of a GitHub instead of a pure git concept, but if there’s a way to do this for generic git repositories I’d like to know, too! Thanks!

Having the forks restructured would not give you automatic updates. The generic solution is:

  1. Add Alice’s repo to your local repo as a remote (git remote add).
  2. Fetch updates from that remote (git fetch).
  3. Create (or update) a dedicated local branch (upstream is a common name for that). If you don’t touch that branch otherwise, you should be able to fast-forward it on updates, unless Alice does a rebase.
  4. Push that branch to your Github repo.
2 Likes

Ah that makes sense, thank you so much! :heart:

Just to confirm, would this mean that it would solely be my local repository’s upstream branch that would be tracking Alice’s repository? I.e. as far as GitHub is concerned, my fork repository hosted on GitHub is still linked to Bob’s fork and GitHub wouldn’t be “aware” that my upstream branch is tracking Alice? In other words, I would be tracking Alice locally via my local upstream branch (with Alice’s repo set as upstream's remote) and not rely on GitHub at all for that purpose, right?

1 Like

Yes, exactly. :slightly_smiling_face:

1 Like

Makes sense. I will use this solution for my forks in this situation. Thank you so much! :grin: :clap: