I try to setup my .gitignore file. My local repo is a clone from my Drupal 8 distro from Acquia Cloud.

(I want to theme my template locally and then, step by step I want to push it to Dev on Acquia Cloud.)

So regarding handeling settings.php, whether or not to ignore settings.php and whether or not use settings.local.php:

If I look in my current settings.php is see this:

// On Acquia Cloud, this include file configures Drupal to use the correct
// database in each site environment (Dev, Stage, or Prod). To use this
// settings.php for development on your local workstation, set $db_url
// (Drupal 5 or 6) or $databases (Drupal 7 or 8) as described in comments above.

I am confused and don't know anymore how to setup my .gitignore file with all this information and whether or not use settings.local.php. Please can somebody advice my what I have to do exactly, so it's setup correctly from the beginning.


The default .gitignore file that ships with your Acquia Cloud git repository is fine as it is. See https://drupal.stackexchange.com/a/193251/23961

I also advised against adding settings.php to your .gitignore file here.

Using settings.local.php is optional. Details about the file are available in the file or the online Drupal documentation as described already here.

  • ok thanks but whats confusion me is that you say 'file that ships with your Acquia Cloud git repository is fine as it is.'. But if i look in that file i see: # Ignore configuration files that may contain sensitive information. sites/*/settings*.php sites/*/services*.yml. Do i have to get rid of sites/*/settings*.php ? And what is the difference between sites/*/settings*.php and settings.php (so without the asterisk) ? – meez Mar 3 '16 at 10:48
  • settings.php is your main configuration file which I think should be kept under version control. settings*.php can represent settings.local.php which is for your local environment only. You may decide to ignore it from git completely. – anavarre Mar 3 '16 at 10:53
  • so if i add only settings*.php to .gitignore it will only ignore e.g. settings.local.php and will not ignore settings.php ? And what still confusing me is if i read in the files and internet documentation they all say that i have to ignore .gitignore because of # Ignore configuration files that may contain sensitive information. But you suggest the opposite? – meez Mar 3 '16 at 11:07
  • If you only use settings.local.php you don't have to use a wildcard character and can enter the complete filename directly if you wish to ignore it on your .gitignore file. The caveat Ignore configuration files that may contain sensitive information is made for files containing sensitive information such as credentials for connecting to the database. On Acquia Cloud you have a require() line that handles connecting to the database without exposing database credentials so you're safe. – anavarre Mar 3 '16 at 11:36
  • But if I add settings*.php to .gitignore, will it not ignore settings.php then? (just to understand). – meez Mar 3 '16 at 12:01

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