Ravindra BagaleCourses & study guides मराठी Track your progress

27. How to Use Git with Jupyter Notebooks for Data Projects

27.3 .gitignore for Data Work

Why. Accidental commit of a 900 MB extract or a .env API key is a bad day. .gitignore tells Git what to skip.

What. Common ignores: __pycache__/, .ipynb_checkpoints/, .env, venv/, large data/raw/* (maybe keep a tiny sample), OS junk .DS_Store.

How.

Write .gitignore early

  1. Create .gitignore before the first big add.
  2. Ignore checkpoints and virtualenvs.
  3. Ignore secrets files by name.
  4. Decide: ignore all of data/raw/ or only *.csv larger patterns.
  5. Keep a small data/raw/sample_orders.csv tracked if you need CI-free demos.

Worked example A — Starter ignore file.

# Python
__pycache__/
.venv/
venv/

# Jupyter
.ipynb_checkpoints/

# Secrets
.env
.env.*
secrets.json

# Data bulk (keep samples if you want)
data/raw/*.csv
data/raw/*.csv.zip
!data/raw/sample_orders.csv

# Outputs can be rebuilt — optional ignore
# outputs/*.png

Worked example B — Check what Git sees.

git status --short

Worked example C — Un-ignore a sample.

The !data/raw/sample_orders.csv line re-includes one small file after a folder pattern ignore — useful for classmates.

Ravindra Bagale's Tip

Pehle gitignore, mag git add .. Ultke kele ki mote CSV history madhe jail.