我使用Git-1.9.0-preview20140217 for Windows。据我所知,这个版本应该解决文件名过长的问题。但对我来说不是。

当然我做错了什么:我做了git配置核心。Longpaths true和git add。然后git提交。一切都很顺利。但是当我现在做一个git状态时,我得到了一个文件名太长的文件列表,例如:

node_modules/grunt-contrib-imagemin/node_modules/ pngquent -bin/node_modules/bin-wrapper/node_modules/download/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-handle-source-errors.js: Filename too long

对我来说,这很简单:只需用Angular生成器("yo Angular ")创建一个Yeoman web应用程序,并从.gitignore文件中删除node_modules。然后重复前面提到的Git命令。

我错过了什么?


当前回答

执行git配置——系统核心。Longpaths true向我抛出了一个错误:

错误:无法锁定配置文件C:\Program Files (x86)\Git\mingw32/etc/gitconfig: Permission denied"

修正了在全局级别执行命令:

git config --global core.longpaths true

其他回答

如果您正在使用加密分区,请考虑将文件夹移动到未加密分区(例如/tmp),运行git pull,然后移动回来。

在windows机器中

以管理员身份运行命令提示符,然后运行以下命令

Git配置——系统核心。longpaths真实

更好的解决方案是从Git中启用longpath参数。

git config --system core.longpaths true

但是一个可行的解决方法是从Git中删除node_modules文件夹:

$ git rm -r --cached node_modules
$ vi .gitignore

在.gitignore文件中的新行中添加node_modules。这样做之后,推送你的修改:

$ git add .gitignore
$ git commit -m "node_modules removed"
$ git push
git config --global core.longpaths true

上面的命令对我很管用。使用“——system”给我配置文件未锁定错误

执行git配置——系统核心。Longpaths true向我抛出了一个错误:

错误:无法锁定配置文件C:\Program Files (x86)\Git\mingw32/etc/gitconfig: Permission denied"

修正了在全局级别执行命令:

git config --global core.longpaths true