我可以使用 Git 维护一个应用程序的两个版本吗?

发布于 2024-11-04 00:02:47 字数 234 浏览 7 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

遗心遗梦遗幸福 2024-11-11 00:02:47

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.

心凉怎暖 2024-11-11 00:02:47

最好让您在构建或运行时在类型之间进行选择,这样您就可以使用一组源。

否则,可以通过分支和合并来实现,但管理起来会更加困难。分叉基本上就是在这个级别进行分支。

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.

有深☉意 2024-11-11 00:02:47

我同意@奥古斯托。您可以在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文