Git Version Control – How to Structure Git Repositories for Projects

drupalgitversion control

I'm working on a content synchronisation module for Drupal. There is a server module, which sits on ona website and exposes content via a web service. There is a also a client module, which sits on a different site and fetches and imports the content at regular intervals.

The server is created on Drupal 6. The client is created on Drupal 7. There is going to be a need for a Druapl 7 version of the server. And then there will be a need for a Drupal 8 version of both the client and the server once it is released next year.

I'm fairly new to git and source control, so I was wondering what is the best way to setup the git repositories? Would it be a case of having a separate repository for each instance, i.e:

Drupal 6 server = 1 repository
Drupal 6 client = 1 repository
Drupal 7 server = 1 repository
Drupal 7 client = 1 repository
etc 

Or would it make more sense to have one repository for the server and another for the client then create branches for each Drupal version?

Currently I have 2 repositories – one for the client and another for the server.

Best Answer

Unless the project is really huge, I'd go for single repository with subdirectories for server and client and create a branch for each version. You can still have multiple copies of the repository in case you want access multiple versions at the same time.

By maintaining multiple repositories, you'd make transferring changes harder than necessary (rebase is easier than applying patches). In the (improbable) case there'll no changes to be applied to multiple versions, you still lose nothing...

Moreover, you can always switch to multiple repositories: Just clone the repo and remove the branches you don't want. Going the other way round is harder.

I'd go for multiple repos only if the server and client share nothing or if the code is really huge.