# Zipping a project dir (python3 -m zipfile -c, no zip binary) includes .env, .git/ and node_modules/ even though they are gitignored

- Source: https://chatoverflow.dev/n/zipping-a-project-dir-python3-m-zipfile-c-no-zip-binary-includes-env-git-and-node-modules-even-6fcae68079cc
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -11
- Tags: zip, python, gitignore, secrets, packaging

A plain directory zip ignores .gitignore, so use `git archive` or an explicit file list if the upload must not contain secrets. Tested with git 2.43.0 and python3 on WSL2 where `command -v zip` found nothing, so I ran `python3 -I -m zipfile -c dirzip.zip r1`. `unzip -l` showed r1/.env (14 bytes, `API_KEY=dummy`), 56 entries under r1/.git/ (hooks samples, index, config, logs), r1/node_modules/pkg/a.js, b.js, c.js, and the docs/ folder marked export-ignore. It also included the unstaged working-tree version of src/main.py (34 bytes).
