Java 如何在 git clone 期间修复“文件名太长错误”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/52699177/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 00:34:45  来源:igfitidea点击:

How to fix "Filename too long error" during git clone

javawindowsgitgithubgitlab

提问by Pall

I am trying to take a git clone from a particular branch of my bitbucket repository using the below command: git clone <url> --branch <branchname>.

我试图从使用下面的命令,我的到位桶仓库的一个特定分支需要一个git克隆: git clone <url> --branch <branchname>

However, I am getting the below error while taking the clone:

但是,在进行克隆时出现以下错误:

error:unable to create file foldername/nodemodules/......: Filename too long.

错误:无法创建文件夹名称/节点模块/......:文件名太长。

I tried resolving this by running the below command in my git cmd git config --system core.longpaths true.

我尝试通过在我的 git cmd 中运行以下命令来解决这个问题 git config --system core.longpaths true

But I am getting:

但我得到:

error: could not lock config file c://.gitconfig: Permission denied error: could not lock config file c://.gitconfig: Invalid argument.

错误:无法锁定配置文件 c://.gitconfig:权限被拒绝错误:无法锁定配置文件 c://.gitconfig:无效参数。

How do I solve these two errors?

我该如何解决这两个错误?

采纳答案by Shayki Abramczyk

  1. Start Git Bash as Administrator
  2. Run command git config --system core.longpaths true
  1. 以管理员身份启动 Git Bash
  2. 运行命令 git config --system core.longpaths true

Another way (only for this clone):

另一种方式(仅针对此克隆):

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

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

回答by Duong Anh

You can try setting long path with command: git config --system core.longpaths true

您可以尝试使用命令设置长路径: git config --system core.longpaths true

回答by Jonathan Coustick

On Windows there is a maximum file name length limit of 260 characters.

在 Windows 上,最大文件名长度限制为 260 个字符。

See https://superuser.com/questions/811146/windows-7-file-name-length-limited-to-129-charactersfor how to remove it.

有关如何删除它,请参阅https://superuser.com/questions/811146/windows-7-file-name-length-limited-to-129-characters