我可以使用 Git 维护一个应用程序的两个版本吗?
我正在使用 Ruby on Rails 编写一个应用程序。该应用程序将交付给至少两种不同的客户类型。基础总是相同的,但有些观点不同。大部分就是这样。目前。
有没有什么方法,例如使用分支,使用相同的代码库并仅分离视图?我阅读了 Git 分支手册,但仍然不确定这是否是实现我需要的最佳方法。
另一个想法是分叉。但是,这样聪明吗?如果我更改了 fork A 的代码中的某些内容,是否可以轻松地将这些更改合并到 fork B 中?
I’m writing an application with Ruby on Rails. This application will be delivered to a minimum of two different customer types. The base is always the same but some of the views differ. That’s mostly it. For now.
Is there any way, for example using branches, to use the same code base and separate only the views, for example? I read the Git manual for branching but am still not sure if this is the best way to achieve what I need.
Another idea would be forking. But, is that clever? If I change something in the code of fork A, is it easy to merge these changes into fork B?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
git 中的分支和分叉一点也不差,因为合并支持非常好(可能是所有 VCM 中最好的)。
就我个人而言,我不喜欢分支或分叉一个项目来提供不同的定制,因为它很快就会变得非常困难,例如,如果您有 15 个不同的部署,您将做什么?
我认为更好的方法是构建应用程序,使其根据某些参数表现不同。我很清楚有时实现非常不同,所以这可能不再有用。
另一种方法是在 GEM 中构建应用程序的核心,它充当应用程序的服务,而您为每个客户端自定义的唯一内容就是视图。当然,GEM 应该足够通用,能够提供您需要的所有服务。
请与我们分享您的决定,因为您的问题没有最佳答案。
Branching and forking in git is not bad at all, as the merge support is great (possible the best of al VCMs).
Personally, I don't like the idea of branching or forking a project to provide different customization as it can very quickly become really difficult, e.g. what are you going to do if you have 15 different deployments?
I think a better approach is to build the application so it behaves differently depending on some parameters. I'm well aware that sometimes the implementations are very different, so this might not be useful anymore.
Another approach is to build the core of your app in a GEM which acts as a service to the application, and the only thing you customize per client are the views. Of course, the GEM should be generic enough to provide all the services you need.
Please share with us what you decided, as there's no best answer for your question.
最好让您在构建或运行时在类型之间进行选择,这样您就可以使用一组源。
否则,可以通过分支和合并来实现,但管理起来会更加困难。分叉基本上就是在这个级别进行分支。
It would probably be better to make you product select between the types at either build or runtime, that way you can use a single set of source.
Otherwise it is possible with branches, and merging, but you'll have more difficulty managing things. Forking is basically branching at this level.
我同意@奥古斯托。您可以在 2 个不同的环境中运行您的应用程序,即 Production_A 和 Production_B。从那里,您可以使用 SettingsLogic 来定义基于 Rails.env 的配置,然后在选择要使用的视图时参考应用程序中的这些设置。
I agree with @Augusto. You could run your app in 2 different environments, ie production_A and production_B. From there, you could use SettingsLogic to define configurations based on Rails.env, then reference those settings in your app when selecting which view to use for example.