如何在Git中跟踪几个共享通用代码的项目? [英] How can I get track of several projects in Git that share common code?

查看:95
本文介绍了如何在Git中跟踪几个共享通用代码的项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了一个网站,现在必须为几个客户克隆该网站。每个客户都希望自定义超出视觉方面,并且不能由配置文件,首选项或类似的东西处理。

I have developed a website that now has to be cloned for several clients. Each client wants customizations that go beyond visual aspects and cannot be handled by profiles, preferences or something like that.

在这种情况下,我想在其中保留一个主存储库使用通用代码Git,然后为每个客户端一个分支。这样,我可以在每个客户(分支机构)中进行个别更改,也可以(使用主服务器)共享共同的更改。

With this scenario, I would like to mantain a master repository in Git with the common code, and then one branch for each client. This way, I can make individual changes in every client (branch) and share common changes as well (using the master).

这种方法正确吗?

谢谢!

推荐答案

这将起作用。

您必须小心合并-您只能从通用代码合并到客户端代码,但是可以合并-选择从客户到普通的个人更改。您还需要弄清楚将代码从common分支传递到client分支的策略—如果没有太多的client-branch代码,您最好在common的基础上重新部署客户更改每次您要更新的代码;进行更多更改后,合并通用代码会容易得多。

You have to be careful with merges -- you can only merge from the common code to the client code, but you can cherry-pick individual changes back from clients to common. You'll also want to work out what your policy will be on bringing code from the common branch to the client branches -- if there's not too much client-branch code, you may be better off rebasing your client changes on top of the common code every time you want to update; with more changes it'd be a lot easier to merge the common code in.

如果您打算采用基础计算方法,请查看 git rerere ,旨在帮助您经常进行基础调整。

If you go for the rebasing approach, take a look at git rerere, which is intended to help you deal with rebasing often.

这篇关于如何在Git中跟踪几个共享通用代码的项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆