Multisites and Git: best practices for local to live?

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
Danny Englander's picture

Greetings, I am struggling with how to setup my Git workflow in terms of my local dev multisite vs. live and how it relates to Git. My setup is that I have added a multisite to my main site which is in Git. So in /sites directory I now have:

subsite1.example.dev, the main site being example.dev. For the main site having a '.dev' extension has not been an issue but now for subsite1.example.dev, I can see this is going to be an issue as on my live site, it will be subsite1.example.com.

If I put some custom modules locally under /sites/subsite1.example.dev/modules/, how are they going to be pulled into /sites/subsite1.example.com/modules/ on my live site? I have googled around but could not really come up with any answers. I did see a reference to using a Git submodule within my main repo but I still don't know how this will work as the directories have different names on local and live. Any suggestions here are welcome, perhaps I am totally approaching this the wrong way. I also saw some references to possibly adding some symbolic links but not sure how to approach this either.

Comments

After searching some more, it

Danny Englander's picture

After searching some more, it turns out this was trivial so for anyone stumbling across this, here is what I did (Drupal 7):

  1. Changed my local subsite1.example.dev folder in /sites to subsite1.example.com
  2. Kept virtual host the way it is (.dev, .local or whatever, don't change this).
  3. Updated sites/sites.php so that my site renders in the browser as .dev but the actual folder is ".com"
    $sites['subsite1.example.dev'] = 'subsite1.example.com';
  4. Updated .gitignore to account for this:
    #multisites
    sites/sites.php
    sites/*.com/files
    sites/*.com/*settings*.php

Now I can add modules and Themes to /sites/subsite1.example.com/ and they will be picked up by Git. I imagine this will not fit everyone's workflow but for this use case, it seems like it will work out fine.

High Rock Media | Drupal Photography | Skype: highrockmedia | Twitter

This takes me half way

topdillon's picture

This takes me half way there.

What changes in this setup when your sites in a multi-site deployment are named like this:

Default site, not used: example
Sub sites, actually used: example.com
anothersite.com
yetanother.org

And how would you setup vhosts locally?

Great Post

rCharles's picture

I've yet to get into GIT, prefering manual backup migrate with SSH tar for file sets, but i can see this tip being very handy in the future.

Git drush drupal

mhamed's picture

using git and drush with drupal resolves many problems of the memory and relieves the servers .
For drush ok but for git need a lot of practice
since i ve got no private account in github.com
I made a git repository on my site's server
i tried to git from my local computer to the remote
The problem is the path where i want git to push or pull
Really i m struggling to make it work
Working with codes is so quick and free from many errors

mhamed

Git user on remote

busla's picture

I am a noob but here is a tip that you probably know about already.

You could create a git user on your server specifically for your repositories, init new the repos in /home and then pull and push as the git user:

git push origin master git@yourservername:~/yourrepo.git

Are u using drush make? Make sure you have ssh keys set up to simplify the process.

Here is my drush/git/ssh adventure using the aegir hosting system:

http://community.aegirproject.org/discuss/git-repos-and-make-files-best-...

git and multisites

mhamed's picture

First with one site all resolved as far as controlling is conserned .
But with multisites under the same base and the same folders of modules themes and libraries it is a kind of all or nothing.
the situation is this:
a drupal site in public_html/ folder.
two symlinks that takes to two parked domain folders within sites/ folder which are :
site1.com
site2.org

these two sites use everything in common with principal site.com
-It happened that one of the sites lost some content
-When I last commit I ve done for all without paying attention to what happened
to reverse the changes will revert to all three sites
+In a way how can one use git to control every site alone.

mhamed

Multisite

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week