Home > Enterprise >  node modules file keeps pushing when ignored
node modules file keeps pushing when ignored

Time:10-09

I have a project that has had node modules folder been pushed to github, my file got over 100MB so i put the node_modules file in the gitignore file :

git_modules/

after doing git add ., then commit and push. it still tries to push node modules and fails.

Trying to remove the node modules using :

git rm -r --cached node_modules

it still doesn't work after adding, committing and pushing. Then trying :

git rm -r --cached .

and it still keeps pushing node modules. now my branch is 5 commits ahead after trying multiple ways and i'm stuck.

when doing :

git status 

it just tells me my branch is 5 commits ahead.

CodePudding user response:

If your branch is 5 commits ahead, that means you did not push (or your branch would be in sync with its remote tracking branch)

Assuming node_modules is not a submodule, or a nested git repositories, and that the .gitignore is at the same level (or above) the node_modules/ folder (IE, not inside it), this should have worked.

Note that it would not have reduced the size of the repository (local or remote).
For that, you will need git filter-repo (python module)

git filter-repo --invert-paths --path node_modules
git push --force
  • Related