简体   繁体   English

克隆时网络驱动器上的 Git 存储库都显示相同的错误:“packfile 与索引不匹配”

[英]Git repositories on network drive all showing same error when cloned: "packfile does not match index"

I've been trying to solve this for hours and I've had 0 luck.我一直试图解决这个问题几个小时,我的运气为 0。 Apologies in advance, I'm fairly novice when it comes to Git.提前道歉,我对 Git 还是个新手。

I have a large amount of Git repositories on a network drive (R: drive).我在网络驱动器(R:驱动器)上有大量 Git 存储库。 All of these repositories are clones of another repository with different changes made in each one.所有这些存储库都是另一个存储库的克隆,每个存储库都进行了不同的更改。

For my work, I frequently need to clone 10+ of these repositories to my local machine (C: drive), so I thought I would make a batch script that would automate the process for me.对于我的工作,我经常需要将 10 个以上的这些存储库克隆到我的本地机器(C:驱动器),所以我想我会制作一个批处理脚本来为我自动化这个过程。

When I ran my batch script (which was essentially just 10+ git clone R:\\INSERT_REPO_HERE C:\\INSERT_DIRECTORY_HERE statements), the process took hours, but this was normal, as my connectivity to the R: drive was poor.当我运行我的批处理脚本(基本上只有 10+ git clone R:\\INSERT_REPO_HERE C:\\INSERT_DIRECTORY_HERE语句)时,这个过程需要几个小时,但这很正常,因为我与 R: 驱动器的连接很差。

The issue:问题:

I was looking into ways to speed up the cloning process, and had found advice to do the following:我正在寻找加快克隆过程的方法,并找到了执行以下操作的建议:

git config --global pack.windowMemory "100m"
git config --global pack.SizeLimit "100m" 
git config --global pack.threads "1"
git config --global pack.window "0"
git config --global core.compression 0
git config --global core.bigfilethreshold 200K

So, I ran those commands on both R: and C: drive.所以,我在 R: 和 C: 驱动器上运行了这些命令。

Now, whenever I clone any repo from the R: drive to my C: drive, I get the following error:现在,每当我从 R: 驱动器将任何repo 克隆到我的 C: 驱动器时,我都会收到以下错误:

Cloning into 'C:\Users\games\Documents\BitBucket\Adapt topics\BU11\BU11.3\src\course\en'...
done.
error: packfile C:/Users/games/Documents/BitBucket/Adapt topics/BU11/BU11.3/src/course/en/.git/objects/pack/pack-2105520c4dd562760badf1555e89a734a7dddfa3.pack does not match index
error: packfile C:/Users/games/Documents/BitBucket/Adapt topics/BU11/BU11.3/src/course/en/.git/objects/pack/pack-2105520c4dd562760badf1555e89a734a7dddfa3.pack does not match index
error: unable to read sha1 file of project/bower.json (15bb293aca56d25d07f9372c81d6d008b41f93cc)


error: packfile C:/Users/games/Documents/BitBucket/Adapt topics/BU11/BU11.3/src/course/en/.git/objects/pack/pack-2105520c4dd562760badf1555e89a734a7dddfa3.pack does not match index
error: packfile C:/Users/games/Documents/BitBucket/Adapt topics/BU11/BU11.3/src/course/en/.git/objects/pack/pack-2105520c4dd562760badf1555e89a734a7dddfa3.pack does not match index
error: unable to read sha1 file of project/js/project.js (02dbe8ec5a71541ce175fada7e0d405359124968)


fatal: unable to checkout working tree
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry with 'git restore --source=HEAD :/'

I have tried --unset ting the global config I set, but it doesn't fix anything.我试过--unset设置我设置的全局配置,但它没有解决任何问题。 As far as I can see, the repos on the R: drive still have all my files, so I haven't lost any data;据我所知,R: 驱动器上的 repos 仍然包含我所有的文件,所以我没有丢失任何数据; but I can't seem to find a way to fix this issue, and re-creating every single repo on the R: drive would take me a very long time too.但我似乎无法找到解决此问题的方法,并且在 R: 驱动器上重新创建每个存储库也会花费我很长时间。

Also, running git fsck --full gives this result, regardless of which repository I do it on:此外,运行git fsck --full会给出这个结果,无论我在哪个存储库上执行它:

Checking object directories: 100% (256/256), done.
error: packfile .git/objects/pack/pack-2105520c4dd562760badf1555e89a734a7dddfa3.pack does not match index
error: packfile .git/objects/pack/pack-2105520c4dd562760badf1555e89a734a7dddfa3.pack cannot be accessed
error: packfile .git/objects/pack/pack-2105520c4dd562760badf1555e89a734a7dddfa3.pack does not match index
error: packfile .git/objects/pack/pack-2105520c4dd562760badf1555e89a734a7dddfa3.pack does not match index
error: packfile .git/objects/pack/pack-2105520c4dd562760badf1555e89a734a7dddfa3.pack does not match index
error: packfile .git/objects/pack/pack-2105520c4dd562760badf1555e89a734a7dddfa3.pack does not match index
Checking connectivity: 369, done.
error: packfile .git/objects/pack/pack-2105520c4dd562760badf1555e89a734a7dddfa3.pack does not match index
error: packfile .git/objects/pack/pack-2105520c4dd562760badf1555e89a734a7dddfa3.pack does not match index
error: packfile .git/objects/pack/pack-2105520c4dd562760badf1555e89a734a7dddfa3.pack does not match index
broken link from    tree fc7405e6041f547e5845cead57f06a38ed4b814f
              to    blob db3d21c232d266d476e028af6fe640b5447dba14

I'm not even entirely sure what a "pack file" even is.我什至不完全确定什么是“打包文件”。 Please, any help would be greatly appreciated!请,任何帮助将不胜感激!

EDIT: I don't know if this helps, but looking in the .git/objects/pack folder of each repository in the R: drive shows that the .pack file was last modified on the same day that I ran the git config commands:编辑:我不知道这是否有帮助,但查看 R: 驱动器中每个存储库的.git/objects/pack文件夹显示 .pack 文件最后一次修改是在我运行git config命令的同一天:

包上次修改

Never store a Git repository on a networked or cloud-synced drive.切勿将 Git 存储库存储在联网或云同步的驱动器上。

What, "never"?什么,“从不”? 1 1

Yes, really, never .是的,真的,从来没有 Why not?为什么不? Because problems like the one you saw will occur.因为像你看到的那样的问题发生。 Just don't do it.只是不要这样做。


1 Obligatory link 1强制性链接

While not an answer to my original post, I have found a workaround that's appropriate for my specific situation.虽然不是我原来帖子的答案,但我找到了一种适合我的具体情况的解决方法。 Basically, I just recreated each repository.基本上,我只是重新创建了每个存储库。

I went into each repository and deleted the ".git" file, then ran我进入每个存储库并删除“.git”文件,然后运行

git init
git add .
git commit -m 'PackFix'

This does mean I've now lost all Git commit history for these repositories, but thankfully (for my specific situation), this isn't a big issue.这确实意味着我现在已经丢失了这些存储库的所有 Git 提交历史记录,但幸运的是(对于我的特定情况),这不是一个大问题。

To anyone reading this in the future, I'd say this thread is more a warning about running --global commands on a network drive (especially if you don't fully understand what they'll do).对于将来读到这篇文章的任何人,我想说这个帖子更像是一个关于在网络驱动器上运行--global命令的警告(特别是如果你不完全理解他们会做什么的话)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM