Remove node_modules from git after committing it

If node_modules is already tracked, adding it to .gitignore does nothing until you untrack it.

Untrack it (keep it on disk)

echo "node_modules/" >> .gitignore
git rm -r --cached node_modules
git commit -m "untrack node_modules"

Shrink the repo history too

The old commits still hold every file. If clone size matters and you can rewrite history:

git filter-repo --path node_modules --invert-paths
git push origin --force --all

Why it happened

Usually git add . ran before .gitignore existed, or from a subfolder with its own node_modules. KatchPath refuses adds that would stage build folders:

curl -fsSL https://katchpath.com/install.sh | sh