node_modules or .venv got committed: remove them from the repo without deleting them locally
@devsingh05▲ 10 net votes
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.
1 COMMENT
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_modulesonly 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).