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

后端 未结 4 851
离开以前
离开以前 2020-12-23 12:36

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 r

相关标签:
4条回答
  • 2020-12-23 12:57

    @tasomaniac . It looks like this

    0 讨论(0)
  • 2020-12-23 13:05

    It's not possible, because your Enterprise GitHub 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 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.

    0 讨论(0)
  • 2020-12-23 13:07

    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/

    0 讨论(0)
  • 2020-12-23 13:15

    If you use GitHub Enterprise then you automatically get access to GitHub Enterprise Cloud i.e. https://github.com/enterprises/mycompany, with the same licence count. This can be linked with SAML to your in-house Active Directory. Then you can simply fork it in GitHub yet keep it within your company's control.

    Sadly you will still need to mirror clone it if you really need it on your in-house instance. However as you control both ends now, you should be able to use GitHub Actions (or Apps) to more intelligently keep them in sync.

    0 讨论(0)
提交回复
热议问题