Set up an awesome default gitignore for your projects

## Why setup a "gitignore" file?

There will be some files you'll never want to commit to Git. Some include:

• Files that contain passwords and other secrets.
• Files that contain runtime environment variables (which themselves might be secrets).
• Large files, such as images and binaries, unless they are essential assets. (A rule of thumb is anything >500 kb is "large" by Git standards.)
• Jupyter notebooks that contain outputs.
• Data file directories. (see: Never commit data into version control repositories)

If you commit them, then:

1. Secrets and other sensitive runtime information may linger in your repository and become exposed to the world.
2. Your repository will explode in history as changes happen to the large binary files.

## How do I set up an awesome "gitignore" file?

Some believe that your .gitignore should be curated. I believe that you should use a good default one that is widely applicable. To do so, go to gitignore.io, fill in the languages and operating systems involved in your project, and copy/paste the one that fits you. If you want an awesome default one for Python:

cd /path/to/project/root
curl https://www.toptal.com/developers/gitignore/api/python


It will have .env available in there too! (see: Create runtime environment variable configuration files for each of your projects)

## How is a .gitignore file parsed?

A .gitignore file is parsed according to the rules on its documentation page. It essentially follows the unix glob syntax while adding on logical modifiers. Here are a few examples to get you oriented:

### Example 1: Ignore all .DS_Store files

These are files generated by macOS' Finder. You can ignore them by appending the following line to your .gitignore:

*.DS_Store


### Example 2: Ignore all files under site/

If you use MkDocs to build documentation, it will place the output into the directory site/. You will want to ignore the entire directory appending the following line:

site/


### Example 3: Ignore all .ipynb_checkpoints directories

If you have Jupyter notebooks inside your repository, you can ignore any path containing .ipynb_checkpoints.

.ipynb_checkpoints