git提交node-modules报文件名过长无法提交问题

当报如下错误时候

fatal: unable to stat 'node_modules/gulp-connect/node_modules/gulp-util/node_modules/dateformat/node_modules/meow/node_modules/normalize-package-data/node_modules/validate-npm-package-license/node_modules/spdx-expression-parse/parser.generated.js': Filename too long

可以使用以下命令来修复:

git config --system core.longpaths true

也可以仅设置当前项目:

git config core.longpaths true

查看设置状态:

git config core.longpaths

 

 

 

 

 

2

- 问题:Filename too long in git for windows

我用Mac端的SourceTree提交了一个Ionic ngCordova 插件,安卓同事用Windows端SourceTree拉取时失败,提示File name too long

解决方法:

网上说的用系统管理员身份打开cmd,输入运行git config --system core.longpaths true并没有解决问题,可能是因为SourceTree客户端使用的是内置git,而不是系统git,切换成系统git问题更多,可能跟配置有关系吧。
最终解决办法是打开Git Bash(开始,输入git,第一个估计就是),输入命令git config --system core.longpaths true,运行。网上90%都是这个样子说的,但还是没解决问题,然后看到有一个博客上说用git config --global core.longpaths true

在git bash中,运行下列命令: git config --global core.longpaths true就可以解决该问题。
--global是该参数的使用范围,如果只想对本版本库设置该参数,只要在上述命令中去掉--global即可。

顺利解决问题。

Tips:可以直接使用SourceTree自带的命令行模式工具,前提是勾选了默认使用Git Bash作为命令行工具。

附上其他答案:

  • Solution1 - set global config, by running this command:
    git config --system core.longpaths true
  • or you can edit directly your specific git config file like below:
    YourRepoFolder -> .git -> config:
[core]
    repositoryformatversion = 0
    filemode = false
    ...
    longpaths = true        <-- (add this line under core section)
Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐