The .gitignore file that comes with Drupal contains some default filename patterns to ignore files that shouldn't be in version control. Let's view the file to see what it contains.
I'll type "less .gitignore" and press Enter. (less is a terminal application used to read text files.)
There are two sections here by default.
- The first ignores the settings.php file (and other files that follow the naming pattern, like settings.local.php) as long as they are in a folder which is in the sites folder.
The asterisk (*) after the "sites" directory is used because, with Drupal, multiple sites can run off the same core codebase by utilizing Drupal's multisite feature. So, the pattern means that the following would all be ignored:
* sites/default/settings.php
* sites/example.com/settings.local.php
* sites/mysite.com/settings.staging.php
- The second section ignores user-generated content. This would typically include files uploaded through the web-interface like images and documents.
You can see that the patterns are similar, but ignore the "files" and "private" directories. Since users can upload files to these directories, and you shouldn't typically version control your site's content with Git, these are standard directories to ignore.
You can also add your own specific files, folders and patterns to ignore directly in this file. We'll talk more about the ways to ignore files and directories in another video, but I wanted to make you aware of this so that you know why the settings.php file and the files directory are not included in the repository.
I'll press "q" to quit the less program.
If I do scroll up and take a look at which files in the "sites" directory are ready to commit, we'll see some text files, the "default.settings.php" file (which is just used as a reference to create your actual settings.php file) and the "example.sites.php" file (which has information about Drupal's multisite feature.)
Now that we know why certain files are not added to the git repository, we're ready to commit these files.