问题
我想知道为什么git clone
似乎不尊重-delta
中的.gitattributes
。
生殖
我准备了一个测试存储库:
.gitattributes
包含*.bin binary -delta
代码:
#!/bin/bash
# setup repository
git init --quiet repo
cd repo
echo '*.bin binary -delta' > .gitattributes
git add .gitattributes
git commit --quiet -m 'attributes'
for i in $(seq 10); do
dd if=/dev/urandom of=data.bin bs=1MB count=10 status=none
git add data.bin
git commit --quiet -m "data $i"
done
cd ..
# create clone repository
time git clone --no-local repo clone
# repack original repository
cd repo
time git repack -a -d
输出:
Cloning into 'clone'...
remote: Counting objects: 33, done.
remote: Compressing objects: 100% (31/31), done.
remote: Total 33 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (33/33), 95.40 MiB | 19.94 MiB/s, done.
real 0m25,085s
user 0m22,749s
sys 0m0,948s
Counting objects: 33, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (21/21), done.
Writing objects: 100% (33/33), done.
Total 33 (delta 0), reused 0 (delta 0)
real 0m5,652s
user 0m4,173s
sys 0m0,178s
观察
时间
clone
总是25秒 repack
25s 5s delta压缩压缩对象
clone
压缩始终为31个对象 repack
压缩 31个对象和 21个对象增量压缩期望
这两项操作(repack
和clone
)都在使用pack-objects
。
因此,我的期望是clone
应尊重-delta
,并且与repack
一样快。
答案 0 :(得分:0)