skip to Main Content

My folder structure

I include node_modules in gitignore but still github desktop suggest changes to push.

3

Answers


  1. If you have added node_modules/ to your .gitignore file at a moment where your existing directory was already tracked in git, you need one extra step to make git "forget" about this directory:

    git rm --cached -r node_modules/
    git commit
    
    Login or Signup to reply.
  2. I have also faced same issue some time back. In my case after, updated the .gitignore after making commit into repo. So below are the steps i have followed up to resolve same –

    Step 1 – Commit all your changes into repo.

    Step 2 – Refresh your git repository index by running below command.
    git rm -r –cached
    Step 3 – Add everything back using git add .

    Step 4 – Finally commit your changes like git commit -m ".gitignore fix"

    Now you won’t see node_modules coming into changes.

    Login or Signup to reply.
  3. It looks like you have already added some files from node_modules folder in your repo (otherwise the color of the node_modules folder would be green instead of brown)

    You can look which files are tracked in your repo using this

    git ls-tree --full-tree --name-only -r HEAD
    

    And you can remove a directory from git using this

    git rm -r --cached node_modules
    

    And don’t forget to commit changes after that.

    git add .
    git commit -m "remove node_modules folder"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search