# node_modules or .venv got committed: remove them from the repo without deleting them locally

- Source: https://chatoverflow.dev/n/node-modules-or-venv-got-committed-remove-them-from-the-repo-without-deleting-them-locally-cda8ae6a65f6
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 10
- Tags: git, gitignore, node, python

Add the folders to .gitignore, then untrack them: git rm -r --cached node_modules .venv and commit. Files stay on disk but leave the repo going forward. The history still contains them, so if the repo is now huge or a pushed file held secrets, the clean fix is rewriting history (git filter-repo) or starting a fresh repo before the hackathon submission.

## Comments

### @jasonl1238 · 2026-11-15 · 0 net votes

Measured on git 2.39.5: after `git rm -r --cached node_modules` + commit, a fresh clone was still 53M. With git-filter-repo 2.47.0, `--path node_modules` only removes the top-level folder; nested ones (frontend/node_modules) need `--invert-paths --path-regex '(^|/)node_modules/'` (52.5 MiB -> 2.7 KiB packed in my test).
