Mar*_*cek 363
答案是正确的,但没有提到如何在公共repo和fork之间同步代码.
这是完整的工作流程(我们在开源React Native之前完成了这个工作):
首先,像其他人所说的那样复制回购(详情请点这里):
private-repo通过Github UI创建一个新的repo(让我们称之为).然后:
git clone --bare https://github.com/exampleuser/public-repo.git
cd public-repo.git
git push --mirror https://github.com/yourname/private-repo.git
cd ..
rm -rf public-repo.git
克隆私人仓库,以便您可以处理它:
git clone https://github.com/yourname/private-repo.git
cd private-repo
make some changes
git commit
git push origin master
为了从公共回购中获得新的热情:
cd private-repo
git remote add public https://github.com/exampleuser/public-repo.git
git pull public master # Creates a merge commit
git push origin master
很棒,您的私人仓库现在拥有来自公共仓库的最新代码以及您的更改.
最后,创建一个拉请求私有仓库 - >公共仓库:
创建拉取请求的唯一方法是对公共仓库进行推送访问.这是因为你需要推到那里的分支(这就是原因).
git clone https://github.com/exampleuser/public-repo.git
cd public-repo
git remote add private_repo_yourname https://github.com/yourname/private-repo.git
git checkout -b pull_request_yourname
git pull private_repo_yourname master
git push origin pull_request_yourname
现在只需创建公共回购通过Github上UI拉请求,如描述在这里.
一旦项目所有者审核了您的拉取请求,他们就可以合并它.
当然可以重复整个过程(只需省略添加遥控器的步骤).
szy*_*dan 91
现在还有一个选择(2015年1月)


ste*_*ano 35
目前的答案有点过时,为清楚起见:
简短的回答是:
这在GitHub上有记录:duplicating-a-repository
bsu*_*tor 25
你必须复制回购
你可以看到这个doc(来自github)
要在不分叉的情况下创建存储库的副本,您需要针对原始存储库运行特殊克隆命令并镜像推送到新存储库.
在下列情况下,您尝试推送的存储库(例如exampleuser/new-repository或exampleuser/mirrored)应该已存在于GitHub上.有关更多信息,请参阅"创建新存储库".
镜像存储库
要完全复制,您需要执行裸克隆和镜像推送.
打开命令行,然后键入以下命令:
Run Code Online (Sandbox Code Playgroud)$ 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如果要在其他位置镜像存储库(包括从原始位置获取更新),则可以克隆镜像并定期推送更改.
Run Code Online (Sandbox Code Playgroud)$ 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与裸克隆一样,镜像克隆包括所有远程分支和标记,但每次获取时都会覆盖所有本地引用,因此它将始终与原始存储库相同.设置推送的URL简化了推送到镜像的过程.要更新镜像,请获取更新和推送,这可以通过运行cron作业自动完成.
Run Code Online (Sandbox Code Playgroud)$ git fetch -p origin $ git push --mirror
https://help.github.com/articles/duplicating-a-repository
DJT*_*ano 14
只需转到https://github.com/new/import。
在“您的旧存储库的克隆 URL”部分中粘贴您想要的存储库 URL,然后在“隐私”中选择Private。
我是 git 新手,所以想在 eclipse GUI 中尽可能多地进行操作(v2020-12;EGit v5.11)。详细信息如下。
\n--->其他答案中的导入方法仅为 Subversion、Mercurial 或 TFS 项目设计。据我亲身了解, GitHub 不支持 git 项目。它可能有效,但为什么要冒险呢?
\n存储库和 GitHub 连接
\neclipse/org.aspectj是原始公共仓库,upstream用于获取的远程
\ncb4/org.aspectj是fork,用于origin推送的远程
\ncb4/remPrivAJ是远程私有仓库,用于private推送的远程
\nI:\\local是本地仓库
对于 github 身份验证,我使用 ssh 和 ed25519 密钥(此 SO 答案中的步骤),因此我的连接 URI 如下所示ssh://git@github.com/<user>/<repo>:
表示法: -> 是鼠标点击或者选择;right-> 是右键单击。
脚步
\n-> Clone a Git Repository and add clone to this view -> Clone URI -> Next\n-> Next-> Next-> Finish填充本地存储库upstream为拉取更新\nright-> Remotes -> Create Remote ->并输入姓名upstream-> Configure fetch -> Create -> Change ->输入原始存储库 URI-> Finish-> Save and Fetch ->所有分支均已下载-> Close-> Advanced在 下Specifications to fetch,删除那里的单独条目Add create/update specification -> Source ref: dropdown并选择master [branch] -> +Add Spec -> Force Update-> Save specifications in upstream configuration -> Finish -> Save and Fetch ->仅下载主分支-> Close就像这样:
\ngit clone --bare git://github.com/eclipse/org.aspectj.git tmpRepo\n<if prompted, enter ssh passphrase>\ncd tmpRepo    \ngit push --mirror ssh://git@github.com:cb4/private.git\n<if prompted, enter ssh passphrase>\ncd ..    \nrmdir tmpRepo /s /q\nprivate推送的新远程right-> Remotes -> Create Remote ->并输入姓名private-> Configure push -> Create -> Change ->输入远程私有存储库 URI-> Finish-> Advanced -> Add All Branches Spec -> Force Update -> Save specifications in origin configuration -> Finish-> Save and Pushmaster 分支被推送-> Close此时,您已将公共存储库分叉到您的私有存储库中。要了解如何将私有更改推送到您的分叉,然后针对原始公共存储库打开拉取请求,请参阅我的答案此处。生成的配置如下所示:
\n