After reading the following posts, I'm still not sure on how to set up a Drupal 8 site with Git.

Apparently, the contributed/ custom modules and themes folders have moved from /sites/all/modules and /sites/all/themes to /modules and /themes, in Drupal 8. When I copy the modules to /sites/all/modules Drupal 8 does recognize them, but when I add modules via UI, they get downloaded to /modules.

Which folders should be committed in a Git repository? Is it generally bad practice to go for sites/all?

Formerly, we had this file and git structure.

↳ www.example.com
  ↳ sites
    ↳ all -> /repo/repo.git/all
↳ repo
  ↳ repo.git
    ↳ all

Now, I imagine it's more complex.

↳ www.example.com
  ↳ modules -> /repo/repo.git/modules
  ↳ themes -> /repo/repo.git/themes
↳ repo
  ↳ repo.git
    ↳ modules
    ↳ themes

What about sites/default/files/conf*?

I understand that this folder is being used for the configuration files.
Is it right that my local developmente environment and the staging/ production environments have their own folder? Is the usage of configuration files necessary when we only tend to have one real, always up-to-date main database (production/live)?
Should the configuration be tracked and deployed with Git? Why?

1 Answer 1


Drupal comes with an example .gitignore file, just rename "example.gitignore" to .gitignore and you have a pretty good starting point. It also comes with a lot of explanations.

Many of your questions go way beyond just answering that should be added to get, there are also some different opinions.

  • Yes, put your modules in /modules and so on, it's a lot easier to work with.

  • Whether or not to commit /vendor depends on your deployment process. if you deploy your git repository directly and have no intermediate deployment process, you probably still want to commit the vendor directory. There are various alternatives, starting from just building an archive yourself and deployment that, to automating that with scripts/build tools to using solutions like platform.sh that run composer install automatically for you. If you use any of those, you likely want to ignore vendor as the example .gitignore file does by default.

  • It's also common practice to have a settings.local.php and add settings.php to git, see instructions in settings.php at the end.

  • I don't understand your repo.git and repo folder examples. It's not more complex than in Drupal 7, just different folders.

  • Yes, you probably want to move your config folder out of files (you need to update the path in settings.php) and commit it. You shouldn't only have one environment, and config allows you to make changes on one site, export it and import it on production. There are many questions here and documentations about this available.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.