18

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."

Ben
  • 14,789
  • 19
  • 67
  • 115
  • 1
    This 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 Answers5

24

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.

enter image description here

  • 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.

    enter image description here

  • 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.

enter image description here

nulltoken
  • 55,645
  • 19
  • 127
  • 125
1

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/

agbodike
  • 1,637
  • 14
  • 27
1

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}\"}"
}
rcedillo
  • 141
  • 4
0

One way is to use the github command line tool called "hub".

Usage: "hub fork [--no-remote] [--org=<ORGANIZATION>]"

cowlinator
  • 4,270
  • 4
  • 27
  • 41
0

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.

Matthias Ronge
  • 7,765
  • 5
  • 38
  • 59