我使用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命令。

我错过了什么?


当前回答

创建.gitconfig并添加

[core]
longpaths = true

您可以在项目位置(不确定)和全局位置创建文件。在我的例子中,位置是C:\Users\{name}\。

其他回答

您应该能够运行该命令

git config --system core.longpaths true

或者手动将其添加到您的Git配置文件中以开启此功能,一旦您使用了受支持的Git版本。它看起来可能是1.9.0或之后的版本。

创建.gitconfig并添加

[core]
longpaths = true

您可以在项目位置(不确定)和全局位置创建文件。在我的例子中,位置是C:\Users\{name}\。

在windows机器中

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

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

git config --global core.longpaths true

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

更好的解决方案是从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