.gitignore Generator · Tutorial

How to write a .gitignore for a Python data project

5 min readbeginnerUpdated

Data projects fill up with virtual environments, notebook checkpoints, datasets and trained models that are far too big for git. You will build a .gitignore that skips them while keeping your code and notebooks.

What you need

Steps

  1. Choose the templates

    Load the example. It ticks Python for caches and virtual environments, Jupyter for checkpoints, plus VS Code, macOS, Windows and Secrets.

  2. Add your data folders

    Under Your own rules the example adds data/raw/ and models/*.pt. Change them to your own folders and file types, such as *.parquet or checkpoints/.

  3. Check a large file

    Type data/raw/2026/sales.csv into the path checker. It is ignored because the folder data/raw/ is ignored, so git won’t even look inside.

  4. Keep small sample data

    To share a tiny sample, keep it in a separate folder such as data/sample/, which isn’t ignored. ! can’t bring back a file inside an ignored folder.

Try it yourself

Opens the .gitignore Generator with this tutorial's sample loaded.

Try it now

Common mistakes

Committing the virtual environment
A .venv folder holds thousands of files that only work on your machine. Commit requirements.txt or pyproject.toml instead.
Ignoring notebooks themselves
Only the .ipynb_checkpoints folders are noise. Keep the .ipynb files, and clear large outputs before committing.

Next steps

Go back to the .gitignore Generator, or keep going with one of these: