Drupal Local and Dev Database I have a Drupal Environment that deploys to GitHub as well as my server. The only issue is I have local database credentials and server database credentials. For now when I do my merge/push, I have to manually change the settings file to make sure I don't connect to the server db and make local changes.

Is there a way to connect to a local database when appropriate and a server database any other time. I tried to use a different connection in the settings.local.php file, but it didn't seem to work.
in your settings.php, uncomment 

# if (file_exists(__DIR__ . '/settings.local.php')) {
#   include __DIR__ . '/settings.local.php';
# }


so it looks like this:

if (file_exists(__DIR__ . '/settings.local.php')) {
  include __DIR__ . '/settings.local.php';
}


then in the same directory edit the settings.local.php to have your local settings.

Then add settings.local.php to your .gitignore file

That way, you can keep local settings that differ from the settings on dev.

So your dev server would have it's own unique settings.local.php file that differs from your local settings.local.php file.

If you need to check your database settings, you can add this at the bottom of settings.php

dump($databases); die();


You should see your correct settings (you can do this on both your local and your dev site to verify, then remove the dump command once you have verified.