git - 不允许浅更新 (git > 1.9)

标签 git

有很多答案指出 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/

相关文章:

python - GitPython:如何提交更新的子模块

Git push : The object is 12311134 byte, 大于此存储库中对象的 1048576 字节限制

git - 无法通过 SSH 进入我的 Bitbucket 存储库 - conq : repository access denied

git - 如何设置 Git 钩子(Hook),以便在推送到 ssh ://peter@foo. com/~/bar.com.git 后,它将转到 ~/bar.com 并执行 git pull?

Git - 不要听嵌套目录中的命令

Git:是否可以使用数字在舞台上添加(或比较)文件?

git - 如何在运行 git filter-branch 后删除旧的历史记录?

git - 如何将 gitosis repo 符号链接(symbolic link)到另一个地方?

Github + Jenkins >> 如何在代码库中触发 "Commit and Push"上的构建?

windows - 如何通过 Cygwin 使用 Windows git 创建的符号链接(symbolic link)