Cloud Platform

Ignoring specific files with .gitignore

Drupal’s default .gitignore file contains only a few basic pieces of information, and is usually located in your website’s docroot directory. Websites hosted on Cloud Platform can make significant changes to this file, and by changing the .gitignore file, you can prevent your repository from bloat, by preventing storage of images or other large data items.

Important

Cloud Platform-hosted websites have a different .gitignore file than the default Drupal version. Since Drupal core upgrades can overwrite this file, be sure to back up your .gitignore file. When the custom file is overwritten by Drupal core, your Git repository can gain or lose information, which can be a risk for data loss or a potential security issue.

.gitignore file differences, by Drupal version

The contents of your website’s .gitignore file depend on the version of Drupal you have installed.

Current Drupal version

You can modify the .gitignore file of your application running the current Drupal version to ignore the settings.php file. This allows you to update the standard settings.php file with the Drupal local settings file checker:

/**
* Load local development override configuration, if existent.
*
* Use settings.local.php to override variables on secondary (staging,
* development, etc) installations of this site. Typically used to disable
* caching, JavaScript/CSS compression, re-routing of outgoing e-mails, and
* other things that should not happen on development and testing sites.
*
* Keep this code block at the end of this file to take full effect.
*/
if (file_exists(DRUPAL_ROOT . '/' . $conf_path . '/settings.local.php')) {
include DRUPAL_ROOT . '/' . $conf_path . '/settings.local.php';
}

Drupal 7

The Drupal 7 default .gitignore file on Cloud Platform appears similar to the following:

# Ignore paths that contain user-generated content.
sites/*/files
sites/*/private

Drupal 7’s default file includes a line to ignore any settings*.php files in the docroot directory. Since many websites commit their settings files to Git as part of their workflow, this addition was problematic and is not present in the current Drupal version.

Excluding additional files

As an example, if you don’t want to commit the default text files to Git, add the following lines to your .gitignore file:

# Ignore default text files
/CHANGELOG.txt
/COPYRIGHT.txt
/INSTALL*.txt
/LICENSE.txt
/MAINTAINERS.txt
/UPGRADE.txt
/README.txt
sites/all/README.txt
sites/all/modules/README.txt
sites/all/themes/README.txt

You can also add additional paths that contain user-generated content, including the same paths that are part of the default file. This can include image files, documents, or other items that should not be placed in the repository.

# Ignore paths that contain user-generated content.
cache/
files/
sites/*/files
sites/*/private
sites/*/files-private
Note

If you are not sure where your website’s private files section is, see Setting the private file directory on Cloud Platform.

Cloud Platform users may have an acquia-files directory, which should be added to your .gitignore file.

Further additions can make sense in the Cloud Platform environment, but you should consider each change carefully to ensure that any changed files that are part of your codebase get backed up.

Did not find what you were looking for?

If this content did not answer your questions, try searching or contacting our support team for further assistance.

Acquia Help

Filter by product:

Cloud Platform common questions