tags:

views:

49

answers:

2

At my company we're using git for a couple of months now (and we're happy about it), but we still don't get git for the full 100%.

Our main product is a website which we offer in different languages (frontend + admin backend). Some of these websites offer features others shouldn't offer (e.g. the type of fields that need to be filled in on a given form, different validation rulesets etc.).

Because these differences are fairly small, we're now using a config file to determine whether or not particular elements should be used by the website. But I guess this will cause problems when the differences between sites will get bigger.

I guess using different branches will make this easier to maintain, but how do you maintain different branches with one shared core? We're not using a deployment tool like Capistrano yet (but are planning to do so), so endless manual cherry-picking from master to all the different branches is not an option at this moment.

So, given this setup, how can branches help us?

master
|
- english
|
- german 
|
- french

(For clarification: this is not about l10n/i18n, but about sharing core features between branches)

A: 

other people had tried it, and say "always ship trunk"

Javier
+1  A: 

Sounds like you'd want to use submodules. This will allow you to keep all the shared functionality as one repository, and the individual sites as their own repositories that track changes in the shared submodule. Lots of nice (though a bit terse, as usual with git documentation) info here, including a webcast.

From the linked page:

Git's submodule support allows a repository to contain, as a subdirectory, a checkout of an external project. Submodules maintain their own identity; the submodule support just stores the submodule repository location and commit ID, so other developers who clone the containing project ("superproject") can easily clone all the submodules at the same revision. Partial checkouts of the superproject are possible: you can tell Git to clone none, some or all of the submodules.

EDIT: If you want to keep the branch structure, I guess you could create a hook script (in .git/hooks/) that checks out each language-specific branch and merges the latest commit from the shared branch any time you commit to that. So you'd have a shared branch, and one branch for each of the languages, and you'd basically make commits to the shared one, and they would automatically be merged into the other ones. I don't think this sounds like a good solutions though, and haven't tried it. If you want to give it a go, look for information about hooks. I think submodules is a more natural fit.

Felixyz
That looks interesting, thanks. But I guess there's no way while using branches to easily update shared code?
vjo
@vjo: see edited answer
Felixyz