简体   繁体   English

git项目的多个版本

[英]Multiple versions of a git project

I have a base website project which I use as a starting point for several customers. 我有一个基础网站项目,我以此为多个客户的起点。 Each customer can have specific changes to the project which I don't want to include in the base project. 每个客户可以对项目进行特定的更改,而这些更改我不想包含在基础项目中。 However sometimes a specific customer feature makes sense to include in the base project and push to all other customers ( such as bug fixes ). 但是,有时将特定的客户功能包括在基础项目中并推送给所有其他客户(例如错误修复)是有意义的。

Right now I have the projects setup with TFS, so that each customer is a branch of the base project. 现在,我已经使用TFS设置了项目,因此每个客户都是基础项目的一个分支。 It works by merging changes to the base into each branch, but it is a terribly slow process. 它通过将对基础的更改合并到每个分支中来工作,但这是一个非常缓慢的过程。 I would like to switch to git (on github), so I can perform these operations locally and reduce the time spent on these operations. 我想切换到git(在github上),所以我可以在本地执行这些操作并减少花在这些操作上的时间。

After reading tons of articles, these are my conclusions so far : 阅读大量文章后,到目前为止,我的结论是:

  • Git branching will not work well in my scenario. Git分支在我的情况下不能很好地工作。 I need different folders for each project, so I can run the sites simultaneously. 每个项目需要不同的文件夹,因此我可以同时运行这些站点。
  • "Submoduling" the base code into each customer repo does not seem like the right solution, as the base is not a subfolder in the project, it "is the project". 将基础代码“子调制”到每个客户回购中似乎不是正确的解决方案,因为基础不是项目中的子文件夹,而是“是项目”。
  • Cherrypicking changesets requires the base remote to be added to the customer project and seems complicated ( and I haven´t been able to make it work so far ) Cherrypicking变更集要求将基本遥控器添加到客户项目中,并且看起来很复杂(到目前为止,我还无法使其正常工作)

So as far as I understand, I should create a new repo for each new customer, copy the code from base initially, and create patches for moving changes between the projects (i am not concerned about history). 因此,据我了解,我应该为每个新客户创建一个新的存储库,首先从库中复制代码,并创建补丁以在项目之间移动更改(我不关心历史)。 I can probably live with this approach, expecially if I can create a tool which automates the process. 我可能可以接受这种方法,特别是如果我可以创建一个使过程自动化的工具,则尤其如此。

Could someone please tell me if I'm on the right track, and how I should go about adding new sites ideally ( having in mind that the workflow should work for several developers). 有人可以告诉我我是否走上正确的路,以及我应该如何理想地添加新站点(请记住工作流应适用于多个开发人员)。

Thanks in advance 提前致谢

I don't see any reason that branches wouldn't work for that. 我看不到任何分支机构对此不起作用的任何理由。 You should be able to have the common commits on a base branch, and create a branch off of that for each customer; 您应该能够在一个基础分支上进行公共提交,并为每个客户创建一个分支。 whenever there are updates to the base branch they would be merged into the different customer branches. 只要基础分支有更新,它们就会合并到不同的客户分支中。 Just as you are currently doing with TFS. 就像您当前正在使用TFS一样。

If you are going to be serving directly out of a git working tree, you would need to have a separate copy of the repository for each site being served to allow you to have a different branch checked out in each. 如果你要直接服务了一个Git工作树,你需要有仓库的单独副本为每个站点上投放让你有不同的分支中的每个检查。 But, you could still have all of the branches contained within a single repository on Github. 但是,您仍然可以将所有分支包含在Github上的单个存储库中。

Another option would be to use a single repository and working tree locally outside of the area handled by the web server and then use a deployment process to copy the data to be served into the appropriate location. 另一种选择是在Web服务器处理的区域之外本地使用单个存储库和工作树,然后使用部署过程将要提供的数据复制到适当的位置。 Since the web server wouldn't be looking directly into a git working tree, you wouldn't necessarily need to have multiple branches checked out at the same time. 由于Web服务器不会直接查看git工作树,因此您不必一定要同时签出多个分支。

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

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