本文介绍了如何从现有回购的分支中创建新的GitHub回购?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 master 新项目分支。现在我想用基于新项目分支的主人创建一个全新的回购。



背景:我有一个存储库,其中包含三个独立的应用程序。它并没有以这种方式开始。回购中最初只有一个应用程序。然而,随着时间的推移,业务需求已经发生变化一个应用程序变成了两个(一个传统版本和一个重写)。一个Web服务被添加了。单独的分支机构被用来包含这三个项目。但是,他们不共享任何代码。因此,将它们拆分成自己的回购库会更简单。

解决方案

我从@ user292677的想法开始,并且改进它来解决我的问题:
$ b $ ol
在github中创建 new-repo

  • cd复制到您想从中提取的旧回购的本地副本,该回购设置用于跟踪新项目分支,该分支将成为新回购
  • $ git push + new-project:master

  • 步骤3.使用推荐的https协议。或者,如果您设置了ssh密钥,您可以执行: $ git push [email protected]:accountname / new-repo + new-project:master



    新的Github回购已完成。结果是;


    • 一个名为 new-repo 的新Github存储库,
      其中 master 对应于旧回购的新项目

    • 保留所有历史记录。实际上,我发现通过使用这种方法,我可以用手工挑选的分支来创建新的回购库,并将其更名为
    • 正如我想要的:
      $ b $ p $ g $ git push [email protected]:accountname / new_repo + new-project:master + site3a:rails3 $ b

      结果是,现有的 site3a 分支现在也移动到新的仓库,并显示为 Rails3中即可。这非常有效:网络图显示新的主站 rails3 ,它们具有完整的历史记录并且彼此之间的关系正确。



      更新2013-12-07:与另一个项目一起使用,并验证此配方仍然有效。

      更新2018-01-11:更新了步骤3.使用https协议的GitHub建议。食谱仍然有效。


      I have master and new-project branches. And now I'd like to create a brand new repo with its master based on the new-project branch.

      Background: I have one repository which contains three independent applications. It didn't start out this way. There was originally just one app in the repo. Over time, however, business needs have changed. One app became two (a legacy version and a re-write.) A web service was added. Separate branches were used to contain the three projects. However, they don't share any code. And so it'd be simpler to have them split out into their own repos.

      解决方案

      I started with @user292677's idea, and refined it to solve my problem:

      1. Create the new-repo in github.
      2. cd to your local copy of the old repo you want to extract from, which is set up to track the new-project branch that will become the new-repo's master.
      3. $ git push https://github.com/accountname/new-repo.git +new-project:master

      Step 3. uses the recommended https protocol. Alternatively if you have ssh keys set up you can do: $ git push [email protected]:accountname/new-repo +new-project:master

      The new Github repo is finished. The result is;

      • a new Github repository named new-repo,
      • whose master corresponds to the old repo's new-project, with
      • all history preserved.

      In fact, I found that by using this method, I could create the new repo with a hand-picked selection of branches, renamed as I wanted:

      $ git push [email protected]:accountname/new_repo +new-project:master +site3a:rails3

      The result is that the pre-existing site3a branch is now also moved to the new repo and will appear as rails3. This works really well: the network diagram shows the new master and rails3 with full history and in their correct relationship to each other.

      Update 2013-12-07: Used this with another project, and verified that this recipe still works.

      Update 2018-01-11: Updated step 3. to use GitHub recommendation for https protocol. Recipe still works.

      这篇关于如何从现有回购的分支中创建新的GitHub回购?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

    09-13 14:06