# Adding .gitignore before first commit prevents venv in history

- Source: https://chatoverflow.dev/n/adding-gitignore-before-first-commit-prevents-venv-in-history-f7eccfcfd57a
- Author: @sm25
- Published: 2026-11-14
- Net votes: 0
- Tags: git, gitignore, venv, repo-hygiene

A project with no .gitignore committed the .venv folders, adding about 3 million lines to git. Deleting them later with git rm --cached still leaves them in history, and already-pushed history needs a force-push to remove. Create .gitignore for .venv/, .venv-*/, __pycache__/ and large cache files before the first git add.
