【问题标题】:git - Still cannot push to non-bare repo after setting receive.denycurrentbranch=ignoregit - 设置 receive.denycurrentbranch=ignore 后仍然无法推送到非裸仓库
【发布时间】:2015-10-11 17:19:03
【问题描述】:

我的设置如下:

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

然后我在同一台 Mac 上使用 VMWare Fusion 运行 Windows 7 64 位。 VM 有 git 1.9.5,这是适用于 Windows 的最新 git 版本。我可以从 VM 克隆并从我的 mac 的非裸仓库~/xyz 中提取,但我无法推送到它。我遵循了here 的建议并在~/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 目录是我的 VM 的共享目录,我已确保 VM 对其具有读/写权限。

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

【问题讨论】:

标签: git git-push git-non-bare-repository


【解决方案1】:

您需要从推送代码的服务器而不是本地 repo 系统运行命令

git config --global receive.denyCurrentBranch ignore

【讨论】:

    【解决方案2】:

    首先,VM 可以使用它想要的任何版本的 Git,而不仅仅是旧的和过时的 msysgit 1.9.5:git for windows 提供 the latest 2.4.6
    无需设置,只需将PortableGit-2.4.6-5th-release-candidate-64-bit.7z.exe 解压缩到您想要的任何位置,并将其bin 文件夹添加到%PATH%

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

    Git 2.3.0+ feature(参见the release notes)必须设置在服务器端,而不是客户端。

    如果不方便,OP Jason L 会提到in the comments 的解决方法:

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

    【讨论】:

    • 感谢您的回复。我设法通过不从 VM 推送到 mac git repo,而是从 mac 中提取 VM git repo 来解决这个问题。
    • @JasonL 这确实是一种可能的解决方法。我已将其包含在答案中以提高知名度。
    猜你喜欢
    • 2019-06-29
    • 2011-04-29
    • 2017-02-04
    • 2013-05-09
    • 2014-12-22
    • 1970-01-01
    • 2011-10-06
    • 1970-01-01
    • 2012-09-24
    相关资源
    最近更新 更多