简体   繁体   English

Git:如何创建一个新分支但项目有所不同

[英]Git: How to create a new branch but somewhat different project

I am going to update my Rails3 project to 4 and at the same time have a clean start project all together. 我将把Rails3项目更新为4,同时将一个干净的启动项目全部合并。 So my solution is to create a new rails4 project and just transfer one by one, what I need in my previous project. 因此,我的解决方案是创建一个新的rails4项目,然后一个接一个地转移,这是我上一个项目所需的。

I was thinking of creating a new branch for my new rails4 project and eventually when I'm done is transfer it back to master and override it. 我当时正在考虑为新的rails4项目创建一个新分支,最终在完成后将其转移回master并覆盖它。 I have come up with two solutions but I don't know what both implications would be. 我想出了两种解决方案,但我不知道这两种含义是什么。 Which should I implement? 我应该实施哪一个?

  1. Just create a new branch git checkout -b v2 and do a git rm -rf on the project. 只需创建一个新的分支git checkout -b v2并在项目上执行git rm -rf Start my new rails app and commit or 启动我的新Rails应用并提交或
  2. Use --orphan? 使用--orphan? I just recently found this option in git. 刚刚在git中找到了这个选项 So I'd use git checkout --orphan v2 do also a git rm -rf on the project and start my new rails app and commit. 因此,我将使用git checkout --orphan v2在项目上也执行git rm -rf并启动我的新Rails应用并提交。

Basically they look almost the same but I was wondering like what would happen if I tried to merge them back to master or override master already? 基本上它们看起来几乎相同,但是我想知道如果我尝试将它们合并回master或覆盖master会发生什么?

my old project already has a lot of clutter and unused codes and I don't want to do the new one on top of those already. 我的旧项目已经有很多混乱的代码和未使用的代码,我也不想在这些代码的基础上再做一个新的代码。 So instead of remove what I don't need, I opted of moving what I need 因此,我选择移除自己不需要的东西,而不是删除不需要的东西

One solution would simply to manage a different repo, if having the history isn't that important. 如果拥有的历史记录不那么重要,则一种解决方案将只是管理其他回购。

Or, if you must keep one repo, go with option 2/ (orphan branch) 或者,如果您必须保留一个存储库,请选择选项2 /(孤立分支)

If the merge to master with override is what worries you, I have summarized the different ways to achieve that in " git command for making one branch like another ". 如果您担心让要覆盖的主体合并,我在“ git命令使一个分支像另一个分支 ”中总结了实现该问题的不同方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM