jem*_*ger 70 git github git-fork
我在github上有一个repo,它包含一个部署到两个不同域的Web应用程序.应用程序在这里和那里有轻微的逻辑分支,根据它部署到哪个域而表现不同.
它已经到了我想要将它分成两个单独的存储库的位置,每个域一个.
Github不会让我把它分成同一个组织.搜索"git duplicate repo"表示我应该克隆并镜像推送它,但这似乎是为了保持两个repos同步,我不想这样做.
最好的方法是什么?如果可能的话,我想在新副本中保留旧的提交历史记录.
lar*_*sks 91
只需创建一个新的存储库并从您的工作副本推送到它:
git clone git@github.com:me/myrepo-original
cd myrepo-original
git remote set-url origin git@github.com:me/myrepo-new
git push origin master
Run Code Online (Sandbox Code Playgroud)
现在你有了一个新的存储库myrepo-new
,它与之相同myrepo-original
.
如果您不需要fork关系(例如,您出于某种原因需要某种解耦的备用仓库),请将您的仓库复制作为轮廓重复,并且larsks的回答很好.
如果你不希望把它叉,请联系Github上支持(support@github.com或https://github.com/support),他们会为你同一组织创建一个叉.(他们对此也不挑剔,你只需为回购提供替代名称,因为帐户中的回购名称必须是唯一的.)
更新:用户Steve Rice在下面的评论中报告说GitHub支持表示支持目前/不再在您的帐户中设置第二个分支.您仍然可以尝试询问他们,因为支持员工可能会这样做 - 但这也可能是政策变化阻止他们这样做.
小智 9
我知道这是一个超级古老的线程,但我偶然发现它寻找答案,随后找到了更好的方法:
将要复制的存储库设为模板存储库。它是存储库设置顶部的一个复选框。执行此操作后,存储库顶部“代码”按钮旁边将出现一个标有“使用此模板”的绿色大按钮。单击该按钮,它将在您想要的任何帐户中创建存储库的副本。
另一种方法是添加要复制的原始仓库作为我们当前仓库的远程仓库。
#create a new repo in the org1 organization called myrepo-new
Run Code Online (Sandbox Code Playgroud)
在本地终端中,运行:
git clone git@github.com:org1/myrepo-new
cd myrepo-new
git remote -v #shows current repo link on github as origin
git remote add name-for-remote https://github.com/org1/repo-old
git remote -v #shows repo-old as name-for-remote
git fetch name-for-remote
git merge name-for-remote/branch-to-get-from-remote
#Now fix any conflicts if present
#If number of files/commits is very high, the desktop client may hang when you try to commit your changes after merge. Try switching to Git Shell if this happens.
git status
git commit -m "commit message"
git push origin master
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
22896 次 |
最近记录: |