我一直試圖解決這個問題幾個小時,我的運氣為 0。提前道歉,我對 Git 還是個新手。
我在網路驅動器(R:驅動器)上有大量 Git 存盤庫。所有這些存盤庫都是另一個存盤庫的克隆,每個存盤庫都進行了不同的更改。
對于我的作業,我經常需要將 10 個以上的這些存盤庫克隆到我的本地機器(C:驅動器),所以我想我會制作一個批處理腳本來為我自動化這個程序。
當我運行我的批處理腳本(基本上只有 10 多個git clone R:\INSERT_REPO_HERE C:\INSERT_DIRECTORY_HERE陳述句)時,這個程序需要幾個小時,但這是正常的,因為我與 R: 驅動器的連接很差。
問題:
我正在尋找加快克隆程序的方法,并找到了執行以下操作的建議:
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
所以,我在 R: 和 C: 驅動器上運行了這些命令。
現在,每當我從 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 :/'
我試過--unset我設定的全域配置,但它沒有解決任何問題。據我所知,R: 驅動器上的 repos 仍然包含我所有的檔案,所以我沒有丟失任何資料;但我似乎無法找到解決此問題的方法,并且在 R: 驅動器上重新創建每個存盤庫也需要很長時間。
此外,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
我什至不完全確定什么是“打包檔案”。請,任何幫助將不勝感激!
編輯:我不知道這是否有幫助,但查看.git/objects/packR: 驅動器中每個存盤庫的檔案夾顯示 .pack 檔案最后一次修改是在我運行git config命令的同一天:

uj5u.com熱心網友回復:
切勿將 Git 存盤庫存盤在聯網或云同步的驅動器上。
什么,“從不”?1
是的,真的,從來沒有。為什么不?因為像你看到的那樣的問題會發生。只是不要這樣做。
1強制性鏈接
uj5u.com熱心網友回復:
雖然不是我原來帖子的答案,但我找到了一種適合我的具體情況的解決方法。基本上,我只是重新創建了每個存盤庫。
我進入每個存盤庫并洗掉“.git”檔案,然后運行
git init
git add .
git commit -m 'PackFix'
這確實意味著我現在已經丟失了這些存盤庫的所有 Git 提交歷史記錄,但幸運的是(對于我的特定情況),這不是一個大問題。
對于將來閱讀本文的任何人,我想說這個執行緒更像是關于--global在網路驅動器上運行命令的警告(特別是如果您不完全了解它們將做什么)。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/336983.html
