在Git管理项目变体的最佳做法? [英] Best practice for managing project variants in Git?

查看:112
本文介绍了在Git管理项目变体的最佳做法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须开发两个共享90%相同代码的Django项目,但在几个应用程序,模板和模型本身中有一些变化。



I我使用Git进行分布式源代码控制。



我的要求是:




    <这两个项目的共同代码是在一个地方开发的(Project1的开发环境)


  • 定期将其合并到第二个项目的开发环境中(Project2)


  • 这些变体不容易封装在应用程序中。 (例如,有一些应用程序,例如Project1和Project2之间的配置文件不同,但也有一个持续的共同演变)


  • Project1和Project2有公共知识库,以便我可以与他人合作


  • 类似的,Project1和Project2应该有开发,演示,分期和生产服务器。

    / li>
  • 但是,在这两种情况下,公用存储库不在同一台服务器上。所以,例如,当我在Project1中开发时,我想要推送到我的github服务器,但是没有Project2的东西在那里。


  • 有一些文件,如local_settings.py,它们在Project1和Project2之间完全不同,但应该在每个项目的多个开发人员之间共享

    / li>


那么管理这种情况的最好方法是什么?



理想的是像过滤的拉,而不是.gitignore说完全忽略这个文件,我可以说从这个repo拉出来忽略这个文件我在文档中看不到任何东西,但是可能会有这样的东西?

解决方案

考虑到这是一个Django / Pinax网站,应用程序,我不建议使用子模块。



变体应在project1分支和project2分支中独立管理,从而无需过滤gitignore结果。



如果您识别出一些非常常见的代码,则可能会在第三个repo中结束,然后可以将子树合并到project1和project2存储库(子树合并策略的含义是在这个SO答案中说明) p>

I have to develop two Django projects which share 90% of the same code, but have some variations in several applications, templates and within the model itself.

I'm using Git for distributed source-control.

My requirements are that :

  • common code for both projects is developed in one place (Project1's development environment)

  • periodically this is merged into the development environment of the second project (Project2)

  • the variations are not easily encapsulated within apps. (eg. there are apps. such as "profiles" which vary between Project1 and Project2 but for which there's also an ongoing common evolution)

  • both Project1 and Project2 have public repositories, so that I can collaborate with others

  • similarly Project1 and Project2 ought to have development, demo, staging and production servers.

  • however, the public repository is not on the same server in both cases. So, for example, when I'm developing in Project1, I want to be able to "push" to my github server, but not have Project2 stuff going there.

  • there are files such as local_settings.py which are completely different between Project1 and Project2, but should be shared between multiple developers of each Project

So what's the best way of managing this situation?

What would seem to be ideal would be something like a "filtered pull" where instead of .gitignore saying "ignore this file entirely", I can say "ignore this file when pulling from that repo" I couldn't see anything quite like that in the documentation, but might there be something like that?

解决方案

Considering it is a Django / Pinax site, with variants scattered around inside several different applications, I would not recommend using submodules.

The variants should be managed independently in project1 branch and project2 branch, removing the need to "filter" a gitignore result.

If you identify some really common codes, they may end up in a third repo you could then "subtree merged" to project1 and project2 repositories (the meaning of subtree merge strategy being illustrated in this SO answer)

这篇关于在Git管理项目变体的最佳做法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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