Remove node_modules from git in vscode

后端 未结 7 1418
误落风尘
误落风尘 2021-01-29 19:37

Getting error while removing node_modules in git, vscode terminal

 git rm -r --cached node_modules

Error:

相关标签:
7条回答
  • 2021-01-29 19:48

    I faced the same issue. Do the below steps -

    • Make .gitignore file.
    • Run below commands in your terminal

      git rm -r --cached node_modules

      git commit -am "node_modules be gone!"

      git push origin master

    That's all!

    You are good to go!

    0 讨论(0)
  • 2021-01-29 19:51
    1. make .gitignore file.
    2. add node_modules/ line to gitignore file
    3. run this command git rm -r --cached . git add . git commit -m "remove gitignore files" git push
    0 讨论(0)
  • 2021-01-29 19:55

    The error means node_modules directory is not under git version control. There are 2 possibilities:

    • They are not added to Git yet. Try running git status command, to see whether they appear as untracked files.

    • It has already been added into your gitignore file. To list all ignored files, try this command: git ls-files --others -i --exclude-standard

    0 讨论(0)
  • 2021-01-29 20:01

    Create .gitignore file and add node_modules there:

    touch .gitignore && echo "node_modules" >> .gitignore
    

    Remove cached data:

    git rm -r --cached .
    

    Update your last commit:

    git add .
    
    git commit --amend --no-edit
    
    git push --force-with-lease
    
    0 讨论(0)
  • 2021-01-29 20:08

    You can remove folders from git without the command-line using vs-code.
    If you want to remove node_modules from git:

    1. rename node_modules to node_modulesx
    2. add node_modulesx to .gitignore (create a .gitignore file if you need to)
    3. commit

    The above 3 steps will remove the node_modules folder from git.

    1. rename node_modulesx back to node_modules
    2. now add node_modules to .gitignore (or change node_modulesx to node_modules in your .gitignore)
    3. commit

    Now your node_modules folder still exists, but will not be committed to git anymore.

    0 讨论(0)
  • 2021-01-29 20:11

    Make .gitignore file in your project directory.

    .gitignore file will look like this

    /Folder_name
    

    Type in below commands in the terminal or equivalent:

    git rm -r --cached Folder_name (remove the directory from git but not delete it from the filesystem/locally)
    
    git commit -m "remove unused directory"
    
    git push origin <your-git-branch> (can be master or develop or others)
    
    0 讨论(0)
提交回复
热议问题