简体   繁体   English

用Git维护项目

[英]Maintaining Project with Git

I have 2 project, and actually these 2 project is about 80% same each other, the mainly difference is just about language and business model, one is for larger audience using english language and have a 9$/month business model, another is using local language with freemium business model. 我有2个项目,实际上这两个项目相差约80%,主要区别在于语言和商业模式,一个是使用英语的大型受众,有一个9美元/月的商业模式,另一个是使用本地语言与免费增值商业模式。

Sometime when I want to add new feature/functionality, I want to add it in both of the project, but also sometime I want to add feature especially just for the local project. 有时当我想添加新的特性/功能时,我想在两个项目中添加它,但有时我想添加功能,特别是只为本地项目。

My question is, how do I maintain these 2 project with git ? 我的问题是,如何使用git维护这两个项目?

  1. Maintain 2 git repository for each project or 为每个项目维护2个git存储库或
  2. Maintain single git repository with 2 mainly branch or 维护单个git存储库,其中2个主要是branch或
  3. Any other suggestion ? 还有其他建议吗?

create three git projects: 创建三个 git项目:

  • one "core" project: it contains the code shared between the other two projects 一个“核心”项目:它包含其他两个项目之间共享的代码

  • your english project: it has a submodule for the core plus specific code 你的英语项目:它有一个核心子模块和特定代码

  • your translated project: it also has a submodule for the core plus specific code 您的翻译项目:它还有一个核心子模块和特定代码

this way you can change your core project, update the submodule references and you'd be good 通过这种方式,您可以更改核心项目,更新子模块引用,您就会很好

Is it possible for you to handle this via configuration and localisation? 您是否可以通过配置和本地化来处理这个问题? That is: 那是:

  • One code base 一个代码库
  • Two localisation files containing English- and local-language strings 两个包含英语和本地语言字符串的本地化文件
  • Configuration for each version of the website determining the payment model/enabled features and changing behaviour accordingly 每个版本的网站的配置确定支付模型/启用的功能并相应地改变行为

My personal view is that one project = one repository. 我个人认为,一个项目=一个存储库。 If your websites are clearly very different then I still think your problem could be handled better by refactoring the common code into modules that can be configured and modified in a sane, controlled way. 如果您的网站明显不同,那么我仍然认为通过将公共代码重构为可以以合理,可控的方式配置和修改的模块,可以更好地处理您的问题。 If you allow each project to have its own git repository then, without hard work, they could easily diverge and contain differences that cannot easily be tracked, introducing subtle bugs or untested functionality. 如果你允许每个项目拥有自己的git存储库,那么在没有努力工作的情况下,它们很容易发生分歧并包含无法轻易跟踪的差异,引入细微的错误或未经测试的功能。

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

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