.gitignore配置node_modules报错:fatal: cannot use node_modules as an excludesfile
解决Git报错“fatal: cannot use node_modules as an excludesfile”
先检查Git配置里是否误把
node_modules设成了排除配置文件:
运行命令:git config --list | grep excludesfile
如果输出里出现node_modules,执行对应命令删掉错误配置:
本地配置:git config --unset core.excludesfile
全局配置:git config --global --unset core.excludesfile确认
.gitignore文件里的配置正确,应该写:node_modules/(加斜杠明确指定是目录,避免Git把它识别成文件)
如果之前已经把
node_modules提交到Git仓库,先清除缓存:
执行命令:git rm -r --cached node_modules
然后提交更改:git commit -m "移除缓存中的node_modules目录"
内容的提问来源于stack exchange,提问作者Siddharth Sharma
相关产品推荐
相关产品推荐

