git拖放由于错误文件名太长而中止

时间:2021-11-28 17:17:46

I'm using Windows as my OS, and working on a project with a friend who's using a Mac. He checked in code to our Github.

我用Windows作为我的操作系统,和一个用Mac的朋友一起做一个项目。

I was trying to git pull everything he did and it aborted with "filename too long" errors of 3rd party code.

我试着把他做的每件事都拉出来,结果被第三方代码的“文件名太长”错误中止了。

What can I do?

我能做什么?

6 个解决方案

#1


183  

The msysgit FAQ on Git cannot create a filedirectory with a long path seems not up to date, as it still links to old msysgit ticket #110. However, according to later ticket #122 the problem has been fixed in msysgit 1.9, thus:

Git上的msysgit FAQ不能创建带有长路径的文件目录,因为它仍然链接到旧的msysgit票据#110。但是,根据后来的第122张机票,问题已经在msysgit 1.9中解决,因此:

  1. Update to msysgit 1.9 (or later)
  2. 更新到msysgit 1.9(或更高版本)
  3. Launch Git Bash
  4. 启动Git Bash
  5. Got to your Git repository which 'suffers' of long paths issue
  6. 到达Git存储库时,会遇到长路径问题
  7. Enable long paths support with git config core.longpaths true
  8. 使用git配置核心启用长路径支持。longpaths真实

So far, it's worked for me very well.

到目前为止,它对我来说效果很好。

Be aware of important notice in comment on the ticket #122

注意在第122号客票上的重要通知。

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

不要再回来抱怨它破坏了Windows资源管理器cmd。exe、bash或您正在使用的任何工具。

#2


56  

Solution1 - set global config, by running this command:

Solution1 -设置全局配置,运行以下命令:

git config --system core.longpaths true

Solution2 - or you can edit directly your specific git config file like below:

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

YourRepoFolder -> .git -> config:

你的repofolder -> .git ->配置:

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

Solution3 - when cloning a new repository: here.

解决方案3 -克隆新存储库时:这里。

#3


17  

A few years late, but I'd like to add that if you need to do this in one fell swoop (like I did) you can set the config settings during the clone command. Try this:

虽然晚了几年,但是我想补充的是,如果您需要在一个立竿见影的时候(就像我所做的那样)进行此操作,您可以在clone命令中设置配置设置。试试这个:

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

git克隆- c核心。longpaths = true < your.url.here >

#4


10  

Open your.gitconfig file to add the longpaths property. So it will look like the following:

打开你的。gitconfig文件添加长路径属性。所以它看起来是这样的:

[core]
symlinks = false
autocrlf = true
longpaths = true

#5


5  

As someone that has ran into this problem constantly with java repositories on Windows, the best solution is to install Cygwin (https://www.cygwin.com/) and use its git installation under all > devel > git.

作为一个经常在Windows上使用java存储库来解决这个问题的人,最好的解决方案是安装Cygwin (https://www.cygwin.com/),并在所有> devel > git下使用它的git安装。

The reason this is the best solution I have come across is since Cygwin manages the long path names so other provided commands benefit. Ex: find, cp and rm. Trust me, the real problem begins when you have to delete path names that are too long in Windows.

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

#6


4  

Try to keep your files closer to the file system root. More details : for technical reasons, Git for Windows cannot create files or directories when the absolute path is longer than 260 characters.

尽量使您的文件更接近文件系统根。更多细节:由于技术原因,当绝对路径超过260个字符时,Windows的Git不能创建文件或目录。

#1


183  

The msysgit FAQ on Git cannot create a filedirectory with a long path seems not up to date, as it still links to old msysgit ticket #110. However, according to later ticket #122 the problem has been fixed in msysgit 1.9, thus:

Git上的msysgit FAQ不能创建带有长路径的文件目录,因为它仍然链接到旧的msysgit票据#110。但是,根据后来的第122张机票,问题已经在msysgit 1.9中解决,因此:

  1. Update to msysgit 1.9 (or later)
  2. 更新到msysgit 1.9(或更高版本)
  3. Launch Git Bash
  4. 启动Git Bash
  5. Got to your Git repository which 'suffers' of long paths issue
  6. 到达Git存储库时,会遇到长路径问题
  7. Enable long paths support with git config core.longpaths true
  8. 使用git配置核心启用长路径支持。longpaths真实

So far, it's worked for me very well.

到目前为止,它对我来说效果很好。

Be aware of important notice in comment on the ticket #122

注意在第122号客票上的重要通知。

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

不要再回来抱怨它破坏了Windows资源管理器cmd。exe、bash或您正在使用的任何工具。

#2


56  

Solution1 - set global config, by running this command:

Solution1 -设置全局配置,运行以下命令:

git config --system core.longpaths true

Solution2 - or you can edit directly your specific git config file like below:

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

YourRepoFolder -> .git -> config:

你的repofolder -> .git ->配置:

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

Solution3 - when cloning a new repository: here.

解决方案3 -克隆新存储库时:这里。

#3


17  

A few years late, but I'd like to add that if you need to do this in one fell swoop (like I did) you can set the config settings during the clone command. Try this:

虽然晚了几年,但是我想补充的是,如果您需要在一个立竿见影的时候(就像我所做的那样)进行此操作,您可以在clone命令中设置配置设置。试试这个:

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

git克隆- c核心。longpaths = true < your.url.here >

#4


10  

Open your.gitconfig file to add the longpaths property. So it will look like the following:

打开你的。gitconfig文件添加长路径属性。所以它看起来是这样的:

[core]
symlinks = false
autocrlf = true
longpaths = true

#5


5  

As someone that has ran into this problem constantly with java repositories on Windows, the best solution is to install Cygwin (https://www.cygwin.com/) and use its git installation under all > devel > git.

作为一个经常在Windows上使用java存储库来解决这个问题的人,最好的解决方案是安装Cygwin (https://www.cygwin.com/),并在所有> devel > git下使用它的git安装。

The reason this is the best solution I have come across is since Cygwin manages the long path names so other provided commands benefit. Ex: find, cp and rm. Trust me, the real problem begins when you have to delete path names that are too long in Windows.

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

#6


4  

Try to keep your files closer to the file system root. More details : for technical reasons, Git for Windows cannot create files or directories when the absolute path is longer than 260 characters.

尽量使您的文件更接近文件系统根。更多细节:由于技术原因,当绝对路径超过260个字符时,Windows的Git不能创建文件或目录。