I've been trying to solve this for hours and I've had 0 luck. Apologies in advance, I'm fairly novice when it comes to Git.
I have a large amount of Git repositories on a network drive (R: drive). 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.
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.
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.
Now, whenever I clone any repo from the R: drive to my C: drive, I get the following error:
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. As far as I can see, the repos on the R: drive still have all my files, so I haven't lost any data; 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.
Also, running git fsck --full
gives this result, regardless of which repository I do it on:
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:
CodePudding user response:
Never store a Git repository on a networked or cloud-synced drive.
What, "never"?1
Yes, really, never. Why not? Because problems like the one you saw will occur. Just don't do it.
CodePudding user response:
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 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.
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).