views:

442

answers:

5

Hi all

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.

+2  A: 

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!

cpharmston
This would essentially mean that they'd end up with lots of critical files that are not under version control.
innaM
Thanx; The only problem with this setup is my customers specific files wont be saved in git. And i dont feel good with that.
jujule
You could easily configure it so that the customer-specific files are in separate folders under source control. Or you can back them up on, you know, floppy disks ;)
cpharmston
imagine i have 'data' and 'settings' folder in my main project folder. If each customer have different files inside these folders, these files cannot be managed under CVS. Of course i have backups but using git for this purpose would be soooo great.
jujule
+2  A: 

In addition to cpharmston's answer, it sounds like you need to do some refactoring to separate out what is truly custom for each client and what isn't. Then you may consider adding additional repositories to track the customizations for each client (entirely new repos, not branches). Then your deployment can pull your "core" from your main repo, and the client-specific stuff from that repo.

Matthew Talbert
Ok thanx; ill focus today on thinking about separating things but this wont be easy as the project is already huge.So what you suggest is having a main core repository with customer specific repos inside (do you suggest git submodules ?).What about github pseudo forks ?
jujule
git submodules might work (I haven't used them). But you want it set up so that when you checkout your customer repo, it checks out the main repo, not the other way around.
Matthew Talbert
+1  A: 

Matthew Talbert is correct, you really need to separate the custom stuff from non-custom stuff. If you can refactor all the core code to be contained in one directory, your clients can use it as a read-only git submodule. The added benefit is that you lock them into an explicit version of the core code. This means that they would have to consciously update to a newer revision, which is what you want for production code.

Igor Zevaka
My project is django based so theres a shared root folder, with differents files and folders in it. Somes are customer specific, others dont. i have to doc on submodules !
jujule
Keep in mind that Django has no requirement of a "shared root folder" or project directory. As long as you've got a settings file, a root URLconf, and your apps all importable somewhere on Python's sys.path, you can structure things however you like. It wouldn't be hard to have a "core" project directory and a totally separate directory for client customizations.
Carl Meyer
+1  A: 

Other answers are correct that you'll be in the best shape for maintenance to the extent that you separate out your core code from the custom per-client code. However, I'll break from the crowd and say that if you're unable to do that (say because you need to add extra functionality to core code for a certain client), DVCS branches would work just fine for what you want to do. Though I'd probably recommend per-directory branches rather than in-repo branches for this purpose (git can do per-directory branches as well, it's nothing but a cloned repo that diverges).

I use hg, not git, but all of my Django projects are cloned from the same base "project template" repo that has utility scripts, a basic common set of INSTALLED_APPS, etc. This means when I make changes to that project template, I can easily merge those common updates into existing projects. This isn't exactly the same as what you're planning, but is similar. You will occasionally have to deal with merge conflicts, if you modify the same area of code in the core that you've already customized for a specific client.

Carl Meyer
Thanks for sharing your different POV.How to you handle customer specific code in your django project ? custom app that is a per-directory branch in your mercurial ?ill also take some time to reorganize the whole project structure
jujule
Well, each Django project is for a specific client. I put as much functionality as possible in reusable apps that I can use for many different projects, only stuff that is client-specific goes in the actual project repo.
Carl Meyer
A: 

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 in the differents branches file makes it easy to use git branches to manage the differents customers and settings !

jujule