Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to fork a public GitHub repo into an enterprise repository?

There exist a public repo for Quick framework here. I'd like to be able to fork this into a private enterprise GitHub repository. Forking would allow all the branches to remain.

the alternative would be to clone the repo and push up only a single branch to the enterprise but then I lose on not having all the branches from the source/original.

update: I ended up pushing all my branches into the enterprise git. if you just do a git push yourRemoteName myNewBranch then it will push the code into that branch on the enterprise git while creating that branch in enterprise GitHub.

like image 573
j2emanue Avatar asked Apr 29 '15 18:04

j2emanue


People also ask

Can you fork a public repository?

The repository for the assignment is public and Github does not allow the creation of private forks for public repositories. The correct way of creating a private frok by duplicating the repo is documented here.

How do I fork a repo to another repo?

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.

Is forking legal in GitHub?

The TOS states you agree to allow viewing and forking. It doesn't state that you agree to allow redistribution or use. If the terms don't explicitly state that you allow those things, then unless your license allows them they aren't allowed.

What does anyone can fork your repository?

Most commonly, forks are used to either propose changes to someone else's project to which you do not have write access, or to use someone else's project as a starting point for your own idea. You can fork a repository to create a copy of the repository and make changes without affecting the upstream repository.


2 Answers

It's not possible, because your GitHub Enterprise (GHE) installation is separate from the public one, so there's no way for the two systems to track each other's branch relationships.

The best you can do is exactly as you describe: Clone the repo, then push it to your GHE installation, and yes, you will then lose the branching relationships across repos.

The other option would be to keep a fork on the public GitHub (GH) repo--possibly keeping it in sync (manually, or with a cronjob) with your GHE repo. Then you'll have two instances of your repo, and the public one would retain branch relationships with the original repo.

Depending on why you need to put this on GHE, it may or may not work. If you're making private contributions, it clearly won't work--as your private contributions would no longer be private. If you want it on GHE due to some corporate policy that all open source projects used internally are kept on the GHE, or something similar, then it would work, with the added administrative overhead of keeping the repo in sync two places.

like image 171
Flimzy Avatar answered Sep 21 '22 02:09

Flimzy


While it isn't possible to fork from the public GitHub directly to your Enterprise installation, you can fork it on the public GitHub and then mirror that forked repository on your enterprise installation.

Steps

  1. Create an empty repository on your enterprise GitHub:
    curl https://github.yourenterprise.com/api/v3/user/repos \   -u "yourUsername" \   -d "{\"name\": \"whatever-repository\", \"private\": true }" 
  2. Create a bare clone of your fork
    git clone --bare https://github.com/publicGitHubUser/forked-repository.git 
  3. Change directories so you are inside the bare clones folder:
    cd ./whatever-repository.git/ 
  4. Push the repository with the --mirror flag to your enterprise GitHub
    git push --mirror https://github.yourenterprise.com/enterpriseGitHubUser/forked-repository.git 

More Information

https://help.github.com/articles/duplicating-a-repository/

like image 33
Pytry Avatar answered Sep 21 '22 02:09

Pytry