有很多答案指出 git 1.9 消除了浅克隆的限制。尽管如此,我使用的是 2.6.1,但仍然存在以下基本问题:
首先,我在某处创建了一个空的 repo:
cd /tmp
mkdir target
cd target
git init
然后,我浅克隆一些 repo 并将上面的 repo 添加为远程:
cd /tmp
git clone --depth 1 git@github.com:muennich/urxvt-perls.git
cd urxvt-perls
git remote add target /tmp/target
最后,我将这个 repo 推送到远程:
git push target master
但后来我得到:
! [remote rejected] master -> master (shallow update not allowed)
error: failed to push some refs to '/tmp/target'
我在这里错过了什么?
最佳答案
我在回答我自己的问题。
我尝试反过来,将 urxvt-perls
添加为 target
的远程,然后从那里获取。由于同样的原因,这失败了,但让我更接近解决方案。来自 git-fetch
人:
--update-shallow
By default when fetching from a shallow repository, git fetch
refuses refs that require updating .git/shallow. This option
updates .git/shallow and accept such refs.
现在,使用此选项可以进行浅层提取。所以前面的问题变成了:是否可以在推送时指定 --update-shallow
行为?好吧,有一个选项:
receive.shallowupdate
If set to true, .git/shallow can be updated when new refs require
new shallow roots. Otherwise those refs are rejected.
不过,我仍在尝试在 github 等中设置它。
关于git - 不允许浅更新 (git > 1.9),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33085672/