使用 Git 维护项目
我有 2 个项目,实际上这 2 个项目彼此大约 80% 相同,主要区别在于语言和商业模式,一个是针对使用英语的更多受众,并且有 9 美元/月的商业模式,另一个是使用本地语言与免费增值商业模式。
有时,当我想添加新的特性/功能时,我想将其添加到两个项目中,但有时我想添加特性,特别是针对本地项目。
我的问题是,如何使用 git 维护这两个项目?
- 为每个项目维护 2 个 git 存储库或
- 维护具有 2 个主要分支的单个 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.
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 ?
- Maintain 2 git repository for each project or
- Maintain single git repository with 2 mainly branch or
- Any other suggestion ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
创建三个 git 项目:
一个“核心”项目:它包含
其他两个之间共享代码
项目
你的英语项目:它有一个
核心子模块以及特定的
代码
有一个核心附加子模块
通过这种方式,
您可以更改核心项目,更新子模块引用,这样就可以了
create three git projects:
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
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
您可以通过配置和本地化来处理这个问题吗?即:
我个人的观点是,一个项目 = 一个存储库。如果您的网站显然非常不同,那么我仍然认为通过将通用代码重构为可以以合理、受控的方式配置和修改的模块,可以更好地处理您的问题。如果您允许每个项目都有自己的 git 存储库,那么,无需努力工作,它们就很容易出现分歧并包含不易跟踪的差异,从而引入微妙的错误或未经测试的功能。
Is it possible for you to handle this via configuration and localisation? That is:
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.