> ## Content Index
> Fetch the complete content index at: https://madewithlove.com/blog/llms.txt
> Use this file to discover other available public pages before exploring further.

# Use gitattributes to keep your tests out of other people's production
- URL: https://madewithlove.com/blog/gitattributes/
- Published: 2015-01-24T14:36:29.000Z
- Updated: 2026-05-29T11:59:01.000Z
- Author: Hannes Van De Vreken
- Tags: Engineering, Tutorials, Tooling

A quick tip here, for all PHP developers out there who author packages registered on [packagist.org](https://packagist.org).  
Add a `.gitattributes` file in the root of your github repository.

The `.gitattributes` file allows you to configure several things, but the most important thing related to composer is the ability to not include certain files and folders into your release.

What I mean by that is the following. When composer installs your package with (that is with `--prefer-dist`) it will pull down a zip file from github or whatever `cvs` you’re using, and extract it. With the `.gitattributes` file you can exclude files and folders to be included in that zip file by adding a line `/folder/file export-ignore`.

When people are using your package, they might not be interested to download your `/tests` folder, or your `.travis.yml` file. Probably all they need is your `src` folder and your `composer.json` file.

Here’s a sample `.gitattributes` file which shows you a lot of files and folders you might want to exclude from your dist-releases.

Even your `.gitattributes` file. How meta.

### Useful other stuff

There’s other useful stuff you can control with the `.gitattributes` file. These things are not related to composer though.

You can let git convert every single end-of-line in text based files to linefeeds (LF). This removes carriage returns (convert CRLF to LF) and makes sure you don’t get weird diffs where the only difference is an invisible character. Enable this by adding `* text=auto` to your `.gitattributes` file. If you want to specify a different end-of-line character on a file type basis, check the [docs](http://git-scm.com/docs/gitattributes#%5Fend%5Fof%5Fline%5Fconversion).

You can also control how [diffs are displayed](http://git-scm.com/docs/gitattributes#%5Fgenerating%5Fdiff%5Ftext) on a per file type basis using the `diff` keyword.

### References:

- More information on the .gitattributes file in the [git documentation](http://git-scm.com/docs/gitattributes)
- This discussion on reddit: [I don’t need your tests in my production.](https://www.reddit.com/r/PHP/comments/2jzp6k/i%5Fdont%5Fneed%5Fyour%5Ftests%5Fin%5Fmy%5Fproduction)