Filename too long in Git for Windows when git clone is aborted in the middle

huangapple go评论75阅读模式
英文:

Filename too long in Git for Windows when git clone is aborted in the middle

问题

I have a problem similar to this question BUT this is not a duplicate since the problem is different.

在那个问题中,有一个文件名太长以致于无法在Windows上使用的问题。提供的答案是应用 git config core.longpaths true

我的问题是,我已经开始克隆一个仓库。在克隆过程中,由于文件名过长的错误,克隆停止了。

我尝试了

git config --system core.longpaths true

错误: 无法锁定配置文件 C:/Program Files/Git/etc/gitconfig: 权限被拒绝

在答案中建议不要全局应用此配置,所以我尝试了

git config core.longpaths true
致命错误: 不在git目录中

好的,我进入了包含仓库的文件夹,然后执行了上述操作,没有问题。已经设置好了。但是中断的克隆无法继续,所以如果我删除文件夹,配置也会消失,对吗?

那么,我如何在不出现这个问题的情况下进行git克隆?
1: https://stackoverflow.com/questions/22575662/filename-too-long-in-git-for-windows

英文:

I have a problem similar to this question BUT this is not a duplicate since the problem is different.

In that question, there was the problem of filenames too long for windows. The answer provided was to apply git config core.longpaths true

My own personal problem is that I have started cloning a repository. *In the middle of * clonning it stopped due to the filename too large error.

I tried

git config --system core.longpaths true

error: could not lock config file C:/Program Files/Git/etc/gitconfig: Permission denied

In the answer it says that it is better to not apply this globally so I did

git config core.longpaths true
fatal: not in a git directory

Ok I cd into the folder with the repo and I did the above and no problem. It is set.
But an interrupted clone can not be continued so if I erase the folder the config set would dissapear too right?

So how can I do the git clonning without this problem?

答案1

得分: 2

使用--global 暂时设置,然后在克隆存储库后取消设置,然后在本地为存储库设置它?

您还可以初始化一个空存储库,本地设置该项,添加一个远程,最后获取该远程,类似于:

$ mkdir my_repo
$ cd my_repo
$ git init
$ git config core.longpaths true
$ git remote add origin https://github.com/repo/whatever.git
$ git fetch origin
英文:

Set it temporarily with --global, and then unset it when the repo is cloned, and then set it locally to the repo?

You can also initialize an empty repository, set the thing locally, add a remote and finally fetch that remote, something like:

$ mkdir my_repo
$ cd my_repo
$ git init
$ git config core.longpaths true
$ git remote add origin https://github.com/repo/whatever.git
$ git fetch origin

huangapple
  • 本文由 发表于 2023年5月11日 16:35:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/76225663.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定