我如何分叉一个公共存储库,但使我的分叉私有?我确实订阅了支持私有存储库。


当前回答

你必须复制一份回购

你可以看到这个文档(来自github)

To create a duplicate of a repository without forking, you need to run a special clone command against the original repository and mirror-push to the new one. In the following cases, the repository you're trying to push to--like exampleuser/new-repository or exampleuser/mirrored--should already exist on GitHub. See "Creating a new repository" for more information. Mirroring a repository To make an exact duplicate, you need to perform both a bare-clone and a mirror-push. Open up the command line, and type these commands: $ git clone --bare https://github.com/exampleuser/old-repository.git # Make a bare clone of the repository $ cd old-repository.git $ git push --mirror https://github.com/exampleuser/new-repository.git # Mirror-push to the new repository $ cd .. $ rm -rf old-repository.git # Remove our temporary local repository If you want to mirror a repository in another location, including getting updates from the original, you can clone a mirror and periodically push the changes. $ git clone --mirror https://github.com/exampleuser/repository-to-mirror.git # Make a bare mirrored clone of the repository $ cd repository-to-mirror.git $ git remote set-url --push origin https://github.com/exampleuser/mirrored # Set the push location to your mirror As with a bare clone, a mirrored clone includes all remote branches and tags, but all local references will be overwritten each time you fetch, so it will always be the same as the original repository. Setting the URL for pushes simplifies pushing to your mirror. To update your mirror, fetch updates and push, which could be automated by running a cron job. $ git fetch -p origin $ git push --mirror

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

其他回答

2021年更新

我是git的新手,所以想在eclipse GUI中做尽可能多的事情(v2020-12;EGit v5.11)。下面的细节。

其他答案中的导入方法仅为Subversion、Mercurial或TFS项目设计。GitHub不支持git项目,这是我亲身体验到的。这可能有用,但为什么要冒险呢?


存储库和GitHub连接

eclipse / org。Aspectj是原始的公共repo,也是用于获取的上游远程 cb4 / org。Aspectj是用于推送的fork和源远程 cb4/remPrivAJ是远程私有回购和用于推送的私有远程 I:\local是本地回购

对于github身份验证,我使用了带有ed25519密钥的ssh(在这个SO答案中的步骤),因此我的连接uri看起来像这样:ssh://git@github.com/<user>/<repo>。

->是鼠标点击或选择;右->是一个右击。


步骤

在github上,将原始的公共回购叉到你的github帐户 在github上,创建空的远程私有回购 在eclipse Git透视图中,将fork克隆到一个新的本地回购并配置它

3.1-> Clone a Git Repository and add clone to this view -> Clone URI -> Next 3.1.1 Enter the URI, Connection, and Authentication info as appropriate -> Next 3.1.2. Select desired branches (I selected only master) -> Next 3.1.3. Enter destination directory for local repo 3.1.4. Import projects now or do it later, then -> Finish to populate the local repo 3.2. Configure the original public repo as a new remote named upstream for pulling down updates 3.2.1. right-> Remotes -> Create Remote -> and enter name upstream 3.2.2. -> Configure fetch -> Create -> Change -> enter original repo URI -> Finish 3.2.3. -> Save and Fetch -> all branches are downloaded -> Close 3.2.4. NOTE: I only wanted the master branch, so did this instead of Step 3.2.3 3.2.5. -> Advanced under Specifications to fetch, delete the lone entry there 3.2.6. Under Add create/update specification -> Source ref: dropdown and select master [branch] -> +Add Spec -> Force Update 3.2.7. -> Save specifications in upstream configuration -> Finish -> Save and Fetch -> only master branch is downloaded -> Close


将远程公共回购复制到远程私有回购并进行配置。这是唯一不能在eclipse中完成的步骤,所以我安装了Git for Windows并使用GitCMD。

像这样:

git clone --bare git://github.com/eclipse/org.aspectj.git tmpRepo
<if prompted, enter ssh passphrase>
cd tmpRepo    
git push --mirror ssh://git@github.com:cb4/private.git
<if prompted, enter ssh passphrase>
cd ..    
rmdir tmpRepo /s /q

将远程私有回购配置为一个名为private的用于推送的新远程

5.1. right-> Remotes ->创建Remote ->,并输入name private 5.2. ->配置推送->创建->更改->输入远端私有回购URI ->完成 5.3. —>高级—>添加所有分支规格—>强制更新—>保存原始配置规格—>完成 5.4. ->推送保存主分支->关闭

至此,您已经将一个公共回购分叉到您的私有存储库中。要了解如何将私有更改推到您的fork,然后打开一个针对原始公共回购的拉请求,请参阅我的回答。最终的配置如下所示:

目前的答案有点过时了,所以,为了清楚起见:

简单的回答是:

做一个公共回购的纯克隆。 创建一个新的私有的。 做一个镜像推送到新的私有。

这在GitHub上有文档:复制一个存储库

现在多了一个选择(2015年1月)

创建一个新的私有回购 在空的回购屏幕上有一个“导入”选项/按钮 点击它,并把现有的github回购url 没有github选项提到,但它与github回购工作太。 完成

去https://github.com/new/import吧。

在“您的旧存储库的克隆URL”部分粘贴您想要的回购URL,并在“隐私”中选择“私有”。

GitHub现在有一个导入选项,可以让你选择任何你想要的新导入的公共或私有存储库