Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I fork the original repo when I've already forked a different fork

I've previously forked jockm/vert.x and sent him a pull request. Now I want to fork vert-x/vert.x (the upstream of jockm/vert.x) and send them a different pull request. But when I click the Fork button, unsuprisingly I end up in my tjcrowder/vert.x fork of jockm/vert.x instead. Is it possible to fork both vert-x/vert.x and jockm/vert.x simultaneously such that I can send each pull requests as appropriate?

I fear the answer may be the same as for this question about the converse situation ("there's no GitHub way, but you can add a remote repo") but I'm hoping otherwise — not least because I don't see how the answer there would allow me to send pull requests to the new remote.

like image 434
T.J. Crowder Avatar asked Sep 09 '12 10:09

T.J. Crowder


People also ask

How do I sync forked with original repo?

Go to your fork, click on Fetch upstream , and then click on Fetch and merge to directly sync your fork with its parent repo. You may also click on the Compare button to compare the changes before merging.

Can I fork a git repo twice?

You are unable to fork a repo twice on Github (as of late 2021) but if you want to build on the same repo multiple times, you can use the "Import Repository" option and feed it the URL used to clone.

Can you fork a forked repository?

You can fork any repo by clicking the fork button in the upper right hand corner of a repo page. Click on the Fork button to fork any repo on github.com. Source: GitHub Guides.


2 Answers

There's no GitHub way (small lie, see below), but there's also nothing to fear.

By definition, your fork of a fork is a fork of the original. When you open a pull request, you get the option to choose both the origin and the destination for your pull request. The choices available there obviously depend on the fork graph, but as long as there is a path in the graph between the 2 repositories, you should be safe. Also, since pull requests live on the website side, you don't even need to add a remote as long as you don't want to use it from git.

Now of course, you might want to reconsider your place in that graph, and make yourself a direct child of the real upstream, but that's mostly unrelated.

As said earlier there is actually a twisted way to have multiple forks, which is to create organizations and fork in them. That way you can "own" multiple repositories in the same graph. But there's really no need to go there.

like image 87
Sigma Avatar answered Oct 06 '22 08:10

Sigma


Thanks to sigma's answer, I saw that not only is the upstream repo available when I go to do a pull request on the jockm/vert.x repo, but all other forks of the upstream repo are as well. So what I ended up doing was:

  1. Deleting my fork of jockm/vert.x and instead forking vert-x/vert.x, since mostly I want to work within the main upstream repo, not jockm's version.
  2. Creating a branch for the commit I wanted to send to jockm, and a separate branch for the commit I wanted to send to vert-x.
  3. Making the relevant changes to each branch.
  4. Sending pull requests for each branch to the relevant repos, since the jockm/vert.x repo is listed as a possible target for the request (along with about 200 other forks).

I used separate branches (basically topic branches) so that those commits would remain the only thing in those pull requests, since subsequent commits on the same branch are automatically added to the pull request, and these changes needed to remain isolated until/unless merged.

like image 28
2 revs, 2 users 95% Avatar answered Oct 06 '22 09:10

2 revs, 2 users 95%