首页 > 解决方案 > 无论存储库如何,Git 总是使用损坏的工作树进行克隆

问题描述

无论是哪个存储库,我都会得到一个损坏的 git 工作树。例如,一个随机存储库:

PS D:\> git clone https://github.com/dylanaraps/pure-bash-bible.git
Cloning into 'pure-bash-bible'...
remote: Enumerating objects: 113, done.
remote: Counting objects: 100% (113/113), done.
remote: Compressing objects: 100% (71/71), done.
                                                                                                                        Receiving objects: 100% (882/882), 242.02 KiB | 3.56 MiB/s, done.
Resolving deltas: 100% (502/502), done.
fatal: this operation must be run in a work tree
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry with 'git restore --source=HEAD :/'

我在 Windows 10 和最新版本的 git 上。git restore --source=HEAD :/工作,但我不应该一直这样做。此外,我已经多次卸载并重新安装了 git。

我认为可能影响它的唯一一件事是这似乎是从安装 VS2019 社区开始的(我将源代码控制设置为无),但这是我所拥有的唯一线索。

这让我发疯!

编辑:不是重复的,因为没有一个解决方案有效。此外,git init,git add .不会产生任何问题。这只是克隆现有的存储库。

标签: git

解决方案


推荐阅读