I've been playing around with Drupal 7 multi-sites lately on my local development environment and was trying to figure out how to add a multi-site to git. Originally I would name my multi-site folder something like subsite.local. Then I realized it would be tricky to add this to git as subsite.local would have no meaning on the live server. This setup assumes that git handles Drupal core files, and regular contrib themes and modules located at /sites/all that would be common to all multi-sites.
Create an Alias
I did some searching and then realized that most of the answer was already given to me in Drupal's example.sites.php (sites.php) file. In there you see this:
$sites['localhost.example'] = 'example.com';
The code implies that there is the capability for Drupal to do it's own aliasing which in fact it can. Since my local virtual host was already setup as subsite.local, I needed to tweak my sites.php file in Drupal's /sites folder. I came up with:
$sites['subsite.local'] = 'subsite.com';
Rename Your Multi-site Folder
Rename subsite.local located in /sites/subsite.local to subsite.com. This allows me to use subsite.local as a URL locally but points to subsite.com folder in /sites/.
I also create some .gitignore defaults to account for this new setup.
Basically this ignores the settings file and files folder just like you would in /sites/default/.
Now clear Drupal's cache - drush cc all - and restart Apache. If all goes well, you have your local dev URL with a matching live site folder to push up to git. Now when you git pull to the remote server, you will have your new multi-site folder in the proper place. Of course you will need to setup the multi-site remotely in Apache or through cPanel. There's plenty of tutorials for this, see the resources section at the end. In addition, you'll need to add a settings file and a files folder but that's pretty standard.
This method might not be ideal in some cases where perhaps you have dozens of multi-sites, each with tons of custom modules. I think in that case it might be a good idea to keep Drupal core separate and at the very least have multi-sites as git sub-modules but I am not sure. For my use case though for now, I like the method I've outlined above.
- Drupal Planet