不允许更新(git> 1.9) [英] Shallow update not allowed (git > 1.9)

查看:366
本文介绍了不允许更新(git> 1.9)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有很多答案指出git 1.9消除了浅层克隆的限制。尽管如此,我使用的是2.6.1,但仍然存在以下基本问题:

b $ b

  cd / tmp 
mkdir target
cd target
git init

然后,我浅入克隆一些回购并将以上回购添加为远程:

  cd / tmp 
git clone --depth 1 git@github.com:muennich / urxvt-perls.git
cd urxvt-perls
git remote add target / tmp / target

最后,我将此回购推送到远程:

  git push target master 

但是我得到:

 ! [remote rejected] master  - > master(浅层更新不允许)
错误:无法将某些文件推送到'/ tmp / target'

我在这里错过了什么?

解决方案

我正在回答我自己的问题。 b

我尝试了另一种方式,将 urxvt-perls 作为 target ,然后从那里获取。由于相同的原因,这失败了,但让我更接近解决方案。从 git-fetch man:

  --update-shallow 
默认情况下,从浅仓库中获取时,git fetch
拒绝需要更新.git / shallow的引用。这个选项
更新.git / shallow并接受这样的参考。

现在,使用此选项可以进行浅取。所以前面的问题变成:是否可以在推送时指定 - update-shallow 行为?那么,有一个选择:

  receive.shallowupdate 
如果设置为true,则.git / shallow可以当新的参考需要
新的浅层根时更新。否则,这些裁判将被拒绝。

尽管如此,我仍然试图在github和类似项目中设置它。

b $ b

There are a lot of answers stating that git 1.9 removes limitations of shallow clones. Nevertheless, I'm using 2.6.1 and still having the following basic issue:

First, I create an empty repo somewhere:

cd /tmp
mkdir target
cd target
git init

Then, I shallow clone some repo and add the above repo as remote:

cd /tmp
git clone --depth 1 git@github.com:muennich/urxvt-perls.git
cd urxvt-perls
git remote add target /tmp/target

Finally, I push this repo to the remote:

git push target master

But then I get:

! [remote rejected] master -> master (shallow update not allowed)
error: failed to push some refs to '/tmp/target'

What am I missing here?

解决方案

I'm answering my own question.

I tried going the other way around and adding urxvt-perls as a remote for target, then fetching from there. This fails because of the same reason but led me closer to a solution. From the git-fetch man:

  --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.

Now, using this option allows the shallow fetch. So the previous question becomes: Is it possible to specify that --update-shallow behavior while pushing? Well, there is an option for that:

receive.shallowupdate
    If set to true, .git/shallow can be updated when new refs require
    new shallow roots. Otherwise those refs are rejected.

I'm still trying to set this in github and the likes, though.

这篇关于不允许更新(git> 1.9)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆