Version Controlling your sites folder, Subversion

While at the DC DrupalCon, I was in a lecture of how to boost you Drupal efficiency through various means and tools. One of course is to have all your code in a some version control system. uses CVS, while many people use Git or Subversion, and there are others besides.

When using a multi-site setup, there is a need to be a bit more careful so that an update to one site doesn't affect other sites. Of course you should be using the sites folders for all the different sites in your multi-site setup (such setup is beyond the scope of this article).

One way for me to keep track of all my code is to have the main code (Drupal core and the sites/all folder) in one repository. Then place each specific sites folder (sites/, sites/ each in their own repository. This way you cleanly separate your code out, and prevents UPDATES from hitting more code than you want it to.

Doing this in SVN can be a little tricky, since I have gotten into crazy LOCKs and Conflicts. Here is how I did it.

  1. Checkout/Create your main repository and add the normal Drupal core, along with the sites/all folder (add in all the common modules and themes as normal.
  2. Commit this to the repository.
  3. Create empty sites folder as needed, leave empty (sites/ ...).
  4. Use the Ignore command on each of these folder.
  5. Commit these updates to the main repository (now all new files added to these folders will be ignored by the main repository.
  6. Checkout/Create new repositories for each of the sites folders, add your files/modules/themes.
  7. Commit each sites folder to its repository.

That is how to cleanly establish sub-repositories inside of a larger one, each exist independently of the others. Now code and commit at your leisure while as you follow the rule of always version controlling your code.