12

我的全局 Git 配置中有以下设置:

[transfer]
    fsckobjects = true

[fetch]
    fsckobjects = true

[receive]
    fsckobjects = true

这些验证克隆数据库中的所有对象都是有效且可访问的。

但是,我想签出的一些存储库有错误,例如oh-my-zsh

git clone https://github.com/robbyrussell/oh-my-zsh.git .oh-my-zsh 
Cloning into '.oh-my-zsh'...
remote: Counting objects: 15624, done.
error: object 2b7227859263b6aabcc28355b0b994995b7148b6: zeroPaddedFilemode: contains zero-padded file modes
fatal: Error in object
fatal: index-pack failed

有没有办法可以为单个“git clone”操作覆盖我的全局 fsckobjects 设置?

4

3 回答 3

13

使用git clone --config key=value并传递您想要跳过的所有参数。对于oh-my-zsh,看起来像这样:

git clone --config transfer.fsckobjects=false \
    --config receive.fsckobjects=false \
    --config fetch.fsckobjects=false \
    git://github.com/robbyrussell/oh-my-zsh.git
于 2016-12-08T00:15:59.280 回答
3

Git 2.19 (Q3 2018) will now allow to get past that error (transformed as a warning).

The test performed at the receiving end of "git push" to prevent bad objects from entering repository can be customized via receive.fsck.* configuration variables.
We now have gained a counterpart to do the same on the "git fetch" side, with fetch.fsck.* configuration variables.

See commit 8a6d052, commit 65a836f, commit d786da1, commit 1362df0, commit 8b55b9d, commit 720dae5, commit 456bab8, commit b2558ab, commit 5180dd2, commit 95d9d4b (27 Jul 2018) by Ævar Arnfjörð Bjarmason (avar).
(Merged by Junio C Hamano -- gitster -- in commit f8ca718, 17 Aug 2018)

fetch: implement fetch.fsck.*

Implement support for fetch.fsck.* corresponding with the existing receive.fsck.*. This allows for pedantically cloning repositories with specific issues without turning off fetch.fsckObjects.

One such repository is https://github.com/robbyrussell/oh-my-zsh.git which before this change will emit this error when cloned with fetch.fsckObjects:

error: object 2b7227859263b6aabcc28355b0b994995b7148b6: zeroPaddedFilemode: contains zero-padded file modes
fatal: Error in object
fatal: index-pack failed

Now with fetch.fsck.zeroPaddedFilemode=warn we'll warn about that issue, but the clone will succeed:

warning: object 2b7227859263b6aabcc28355b0b994995b7148b6: zeroPaddedFilemode: contains zero-padded file modes
warning: object a18c4d13c2a5fa2d4ecd5346c50e119b999b807d: zeroPaddedFilemode: contains zero-padded file modes
warning: object 84df066176c8da3fd59b13731a86d90f4f1e5c9d: zeroPaddedFilemode: contains zero-padded file modes

The motivation for this is to be able to turn on fetch.fsckObjects globally across a fleet of computers but still be able to manually clone various legacy repositories by either white-listing specific issues, or better yet whitelist specific objects.

于 2018-08-19T13:30:04.843 回答
1

如果您只需要最新版本 - 例如自动安装 - 我一直在我的脚本中使用它(例如):

git clone --depth 1 https://github.com/ohmyzsh/ohmyzsh

它不会克隆整个 repo 历史记录,只是克隆最新版本,无论如何对于自动安装应该没问题。

(I am quite sure I did not come up with this myself, but I am unable to retrace it to the original source).

于 2018-04-25T17:50:46.047 回答