Is it possible to 'fork again' in github? I had forked a public repository, but then I became owner of an organization and I'd like to fork the same original repository again (not my fork). However, it seems that in order to choose to fork as an organization you can only do so by clicking on the 'fork' button, which because I had originally forked it, that button now says "your fork" to take me to my original fork, but doesn't let me choose "fork as organization."
-
1This should probably be directed to [webapps.stackexchange](http://webapps.stackexchange.com/) or [GitHub Support](https://github.com/contact). – Jordan Running Jan 26 '12 at 18:51
5 Answers
How about
- Deleting your personal repository (making sure you've got a local clone/backup) by going to
https://github.com/:your_login/:repo_identifier/admin
then clicking the Delete Repository button in the Danger Zone.
Browsing to the upstream repository GitHub page (
https://github.com/:upstream_login/:repo_identifier
) should now display a Fork button.Clicking the Fork button will display a dialog (similar to the one below) requesting if you're willing to fork to your personal area or your organization area.
Once this is done, you can add to your local repository a remote pointing to the newly forked repository in your organization area.
$ git remote add your_organization git@github.com:your_organization/repo_identifier.git
UPDATE:
I may have found a (hackish) way to fulfill your request
- Make sure you're logged in in GitHub
- Open a new tab and go to
https://github.com/:upstream_login/:repo_identifier/fork
- This should display a page proposing to fork the upstream repository to your organization area.
- Click on the button :)
Warning: this rely on an undocumented GitHub feature and this hack may stop working at any time. However, once the fork is created, even if the hack stops working, it is safe to think the fork should remain.
![](../../users/profiles/335418.webp)
- 55,645
- 19
- 127
- 125
-
is that really the only way? i don't want to delete my fork, isn't there a way to have both? – Ben Jan 26 '12 at 23:04
-
@Ben I've added another (tested) workaround. Use it while it works :) – nulltoken Jan 27 '12 at 09:35
You can fork to an organization using curl & the github API. The below example will fork the faraday ruby gem to the "your_organization" organization:
curl https://api.github.com/repos/technoweenie/faraday/forks \
-d '{"organization": "your_organization"}'
Note: you will want to change "your_organization" to the actual name of the organization you want to fork to. You may also need to authenticate to successfully fork.
Forking instructions via github developer documentation:
https://developer.github.com/changes/2012-11-27-forking-to-organizations/
![](../../users/profiles/3353794.webp)
- 1,637
- 14
- 27
UPDATE
For some reason the url https://api.github.yourdomain
does not redirect the requests to the latest API version, at least in our Github Enterprise. So none of the previous procedures work for me.
Following the latest documentation this is how you can do it using the latest API version which is v3
at this point.
curl -k -u "user":"password" https://github.com/api/v3/repos/USER/REPO/forks -d '{"organization": "YOUR_ORGANIZATION"}'
I've created a little function in bash to do it easier.
usage: git_fork_to_org <repo> <organization>
e.g $ git_fork_to_org rgcr/dotfiles my_awesome_organization
git_fork_to_org(){
repo=$1
org=$2
[ $# -ne 2 ] && >&2 printf "usage: git_fork_to_org <repo> <organization>\n" && return 1
printf "github user > "
read -n gh_user
printf "github password > "
read -ns gh_password
printf "${gh_user} > forking ${repo} to ${org}\n"
curl -k -u "${gh_user}":"${gh_password}" \
https://github.com/api/v3/repos/${repo}/forks \
-d "{\"organization\": \"${org}\"}"
}
![](../../users/profiles/4978958.webp)
- 141
- 4
One way is to use the github command line tool called "hub".
Usage: "hub fork [--no-remote] [--org=<ORGANIZATION>]"
![](../../users/profiles/1698736.webp)
- 4,270
- 4
- 27
- 41
The page for this is located at
https://github.com/:upstream_login/:repo_identifier/fork
It says that you have already forked the repository and allows to “fork again to a different accout” where your organization is shown.
![](../../users/profiles/1503237.webp)
- 7,765
- 5
- 38
- 59