我有 master 和 new-project 分支.现在我想基于 new-project 分支用它的 master 创建一个全新的 repo.
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.
背景:我有一个包含三个独立应用程序的存储库.它不是这样开始的.存储库中最初只有一个应用程序.然而,随着时间的推移,业务需求发生了变化.一个应用程序变成了两个(旧版本和重写版本).添加了一个 Web 服务.单独的分支用于包含三个项目.但是,它们不共享任何代码.因此,将它们拆分为自己的存储库会更简单.
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.
推荐答案我从@user292677 的想法开始,并对其进行改进以解决我的问题:
I started with @user292677's idea, and refined it to solve my problem:
新的 Github 存储库已完成.结果是;
The new Github repo is finished. The result is;
- 一个名为 new-repo 的新 Github 存储库,
- 其master对应于旧repo的new-project,与
- 保留所有历史记录.
- 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 git@github:accountname/new_repo +new-project:master +site3a:rails3
结果是,先前存在的 site3a 分支现在也移动到新的存储库中,并将显示为 rails3.这非常有效:网络图显示了新的 master 和 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.
2013-12-07 更新:将其用于另一个项目,并验证此配方仍然有效.
Update 2013-12-07: Used this with another project, and verified that this recipe still works.
更新 2018-01-11:更新了第 3 步,以使用 GitHub 推荐的 https 协议.配方仍然有效.
Update 2018-01-11: Updated step 3. to use GitHub recommendation for https protocol. Recipe still works.
更多推荐
如何从现有存储库中的分支创建新的 GitHub 存储库?
发布评论