问题情况
情形 1:使用 git clone
后,拉取的文件夹中只有 .git
文件夹,其他内容均没有拉下来。使用 git status -s
命令,可以看到所有文件都显示已被删除的状态。
情形 2:本地在切换分支时,出现如下报错信息,然后分支切换失败:
error: invalid path 'folder_1/....../name_1.txt'
error: invalid path 'folder_1/....../name_2.txt'
error: invalid path 'folder_1/....../name_3.txt'
error: invalid path 'folder_1/....../name_4.txt'
问题原因
代码中包含 NTFS 文件系统不支持的文件名。(源代码可能是在 Mac 或 Linux 等其他系统下开发的)
Git 在 Windows 下默认开启了 NTFS 保护机制,导致包含不满足 NTFS 文件名的项目无法被成功拉取,且无法切换到这些不满足 NTFS 文件名规范的文件夹中。
解决方法
关闭 NTFS 保护机制的配置,操作命令如下:
git config core.protectNTFS false
关于这个配置,Git 的描述如下:If set to true, do not allow checkout of paths that would cause problems with the NTFS filesystem, e.g. conflict with 8.3 “short” names. Defaults to true on Windows, and false elsewhere.
开启该配置后,执行 git checkout
命令即可。在 checkout 时会打印这些文件拉取失败的日志,但能够成功拉取其他文件:文章来源:https://www.toymoban.com/news/detail-757190.html
error: unable to create file folder_1/....../name_1.txt: No such file or directory
error: unable to create file folder_1/....../name_2.txt: No such file or directory
error: unable to create file folder_1/....../name_3.txt: No such file or directory
error: unable to create file folder_1/....../name_4.txt: No such file or directory
在拉取完成后,执行 git status -s
命令后,会显示这些不满足 NTFS 文件名的文件均为被删除的状态。文章来源地址https://www.toymoban.com/news/detail-757190.html
到了这里,关于Git|error invalid path 报错的解决方法的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!