17

Im new to GIT and dont know yet how much it will fit my needs, but it looks impressive.

I have a single webapp that i use for differents customers (django+javascript)

I plan to use GIT to handle these differents customers version as branches. Each customer can have custom files, folders and settings, improved versions... but the should share the same 'core'. We are a small team and suscribed a github account.

Is the branch the good way to handle this case ?

About the settings file, how would you proceed ? Would you .gitignore the customer specific settings file and add a settings.xml.sample file for example is the repo ?

Also, is there any way to prevent some files to be merged into master ? (but commited to the customer branch). For example, id like to save some customer data to the customer branch but prevent from to being commited to master.

Is the .gitignore file branch-specific ? YES

EDIT After reading all your answers (thanks!) i decided to first refactor my django project structure to isolate the core and my differents apps in an apps subfolder. Doing this makes a cleaner project, and tweaking the .gitignore file makes it easy to use git branches to manage the differents customers and settings !

Ju.

4

5 回答 5

6

I would not use branches to accomplish what you are trying to do.

In source control, branches are intended to be used for things that are meant to be merged back into trunk. For example, Alex Gaynor spent his summer of code working on a branch of Django that allows for support for multiple databases, with the goal of eventually merging it back into the Django trunk.

Checkouts (or clones, in Git's case) might better suit what you are trying to do. You would create a repo containing all of the project's base files (and .sample files, if you will), and clone the repo to all the various locations you wish to deploy the code. Then manually create the configuration and customization files at each deployment (take care not to add them to the repo). Whenever you update the code in the repo, run a pull on each deployment to update the code. Viola!

于 2009-09-16T00:37:38.043 回答
6

除了 cpharmston 的回答之外,听起来您需要进行一些重构以区分每个客户真正自定义的内容和非自定义内容。然后,您可以考虑添加额外的存储库来跟踪每个客户端的自定义(全新的存储库,而不是分支)。然后,您的部署可以从您的主存储库中提取您的“核心”,并从该存储库中提取特定于客户端的内容。

于 2009-09-16T00:46:46.400 回答
2

其他答案是正确的,只要您将核心代码与自定义的每个客户端代码分开,您将处于最佳维护状态。但是,我会从人群中脱颖而出并说如果您无法做到这一点(例如因为您需要为某个客户端的核心代码添加额外的功能),那么 DVCS 分支可以很好地满足您的需求. 虽然我可能会为此目的推荐每个目录分支而不是回购分支(git 也可以执行每个目录分支,但它只不过是一个不同的克隆回购)。

我使用 hg,而不是 git,但我所有的 Django 项目都是从具有实用程序脚本、一组基本通用 INSTALLED_APPS 等的同一基本“项目模板”repo 克隆的。这意味着当我对该项目模板进行更改时,我可以轻松地将这些常见更新合并到现有项目中。这与您的计划不完全相同,但相似。如果您修改内核中已为特定客户端定制的相同代码区域,您有时将不得不处理合并冲突。

于 2009-09-16T13:30:00.000 回答
1

在阅读了您的所有答案(谢谢!)之后,我决定首先重构我的 django 项目结构,以将核心和我的不同应用程序隔离在应用程序子文件夹中。这样做会使项目更干净,并且调整不同分支文件中的 .gitignore 可以轻松使用 git 分支来管理不同的客户和设置!

于 2009-09-17T08:09:53.417 回答
1

Matthew Talbert 是正确的,您确实需要将自定义内容与非自定义内容分开。如果您可以将所有核心代码重构为包含在一个目录中,那么您的客户可以将其用作只读 git 子模块。额外的好处是您将它们锁定在核心代码的显式版本中。这意味着他们必须有意识地更新到较新的版本,这是您想要的生产代码。

于 2009-09-16T00:50:30.097 回答