git - 在设置了receive.denycurrentbranch=ignore之后仍无法推送到非裸库

3

我的设置如下:

我在Mac上运行git版本2.3.2(Apple Git-55),有一个非裸的git存储库位于~/xyz

然后,我在同一台Mac上使用VMWare Fusion运行Windows 7 64位。该虚拟机具有最新的Windows git版本1.9.5。从虚拟机中,我可以克隆和拉取来自Mac的非裸repo ~/xyz,但无法向其推送。我已按照这里的建议,在~/xyz上设置了receive.denycurrentbranch=ignore,但仍然给出相同的错误消息:

remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error:
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some
remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.

我还尝试过设置 receive.denycurrentbranch=updateInstead,但仍然出现相同的错误信息。

每次更改任何git设置后,我都重新启动了计算机。

目录~/xyz是我的虚拟机共享目录,并且我已确保虚拟机具有对其的读/写访问权限。

请问,有人有什么想法吗?


2个回答

5
您需要从推送代码的服务器上运行命令,而不是从本地代码库系统运行命令。
git config --global receive.denyCurrentBranch ignore

1

首先,VM可以使用任何版本的Git,而不仅仅是旧的和过时的msysgit 1.9.5版本:Git for Windows提供了最新的2.4.6版本
无需设置,只需在任何位置解压PortableGit-2.4.6-5th-release-candidate-64-bit.7z.exe并将其bin文件夹添加到%PATH%中。

我也尝试过设置receive.denycurrentbranch=updateInstead

那个Git 2.3.0+的功能(请参阅发布说明)必须在服务器端设置,而不是客户端。

如果这不方便,OP Jason L评论中提到了解决方法

不要从VM推送到Mac git repo,而是从Mac拉取VM git repo。


谢谢您的回复。我设法解决了这个问题,方法是不从虚拟机推送到Mac git仓库,而是从Mac拉取虚拟机git仓库。 - Jason L
@JasonL 那确实是一个可行的解决方法。我已经将其包含在答案中以增加可见性。 - VonC

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接