If I understand forking, it conceptually involves the following steps:
- Mirror-clone the source repo to a target repo
- Set an "upstream" remote on the target repo, pointing to the source repo
- Some other stuff, like email subscriptions, etc. (not important for this question)
This is how it looks like:
Original <──upstream─── Forked
(server) (server)
↑
│origin
│
(local)
The key difference from cloning is that these steps are server-side, not local. How do I replicate this manually, on the git command line?
Here's what I've done so far:
- Clone the source repo to a local repo
- Change the "origin" remote to point to the intended target repo
- Add an "upstream" remote pointing to the source repo
At this stage, I have everything set up on the local repo. I can sync changes between the original and forked repos using an intermediate local clone. So this is what I have:
Original Forked
(server) (server)
↑ ↑
│ │origin
│ │
└───────upstream─── (local)
Now how do I push this link to the server i.e. make the original repo an upstream remote of the server-side forked repo, to match the first diagram?
Note that this question is not GitHub-specific - I might also want to do this with BitBucket. Ideally, I should be able to do this across sites as well. I've read lots of similar questions here on SO, but there's no clear answer.