---
title: "Ignoring specific files with .gitignore"
date: "2024-02-14T06:18:38+00:00"
summary: "Optimize your Drupal site's Git workflow by customizing the .gitignore file. Learn how to prevent repository bloat, manage user-generated content, and adapt to different Drupal versions for efficient version control."
image:
type: "page"
url: "/acquia-cloud-platform/ignoring-specific-files-gitignore"
id: "6f49986d-3406-4682-ada0-f02dd1c63f8e"
---

Drupal’s default `.gitignore` file contains only a few basic pieces of information, and is usually located in your website’s [docroot](/definitions/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](http://git-scm.com/) 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](/service-offerings/guide/software-life-cycle#supported-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](/service-offerings/guide/software-life-cycle#supported-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 about the location of your website’s private files section, see [Setting the private file directory on Cloud Platform](/acquia-cloud-platform/help/93091-setting-private-file-directory-acquia-cloud "Setting the private file directory on Acquia Cloud").

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.