git pull中止,错误文件名太长


git pull aborted with error filename too long

我正在使用Windows作为我的操作系统,并且正在与使用Mac的朋友一起进行项目。他在我们的Github中检入了代码。

我试图用git拉出他所做的所有操作,但由于第3方代码的"文件名太长"错误而终止。

我该怎么办?


关于Git的msysgit常见问题解答无法创建路径较长的文件目录,因为它仍链接到旧的msysgit凭单#110,因此路径似乎不是最新的。但是,根据后来的故障单#122,该问题已在msysgit 1.9中修复,因此:

  • 更新到msysgit 1.9(或更高版本)
  • 启动Git Bash
  • 转到您的Git存储库,这会"困扰"长距离问题
  • 使用git config core.longpaths true启用长路径支持
  • 到目前为止,对我来说效果很好。

    请注意122号票上的重要通知

    don't come back here and complain that it breaks Windows Explorer,
    cmd.exe, bash or whatever tools you're using.


    解决方案1-通过运行以下命令来设置全局配置:

    1
    git config --system core.longpaths true

    解决方案2-或您可以直接编辑特定的git配置文件,如下所示:

    YourRepoFolder-> .git-> config:

    1
    2
    3
    4
    5
    [core]
        repositoryformatversion = 0
        filemode = false
        ...
        longpaths = true        <-- (add this line under core section)

    解决方案3-克隆新存储库时:此处。


    晚了几年,但是我想补充一点,如果您需要一口气做到这一点(就像我一样),则可以在clone命令期间设置配置设置。试试这个:

    1
    git clone -c core.longpaths=true <your.url.here>


    打开your.gitconfig文件以添加longpaths属性。因此,它将类似于以下内容:

    1
    2
    3
    4
    [core]
    symlinks = false
    autocrlf = true
    longpaths = true


    由于Windows上的Java存储库经常遇到此问题,因此最好的解决方案是安装Cygwin(https://www.cygwin.com/),并在all> devel> git下使用其git安装。

    这是我遇到的最佳解决方案的原因是因为Cygwin管理长路径名,因此其他提供的命令也会受益。例如:查找,cp和rm。相信我,当您必须删除Windows中太长的路径名时,真正的问题就开始了。


    在Windows上,以管理员身份运行" cmd"并执行命令。

    1
    2
    "C:\\Program Files\\Git\\mingw64\\etc>"
    "git config --system core.longpaths true"

    ,或者您必须在安装git的目录下使用chmod。

    或手动通过转到路径" Git \\\\ mingw64 \\\\ etc"来手动更新文件

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    [http]
        sslBackend = schannel
    [diff"astextplain"]
        textconv = astextplain
    [filter"lfs"]
        clean = git-lfs clean -- %f
        smudge = git-lfs smudge -- %f
        process = git-lfs filter-process
        required = true
    [credential]
        helper = manager
    **[core]
        longpaths = true**

    请尝试使文件更靠近文件系统根目录。更多详细信息:出于技术原因,当绝对路径超过260个字符时,Windows的Git无法创建文件或目录。