我在使用Git 1.9时出错。
当我尝试"git push“时,我收到以下错误:
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'.因此,我的第一步是在这个论坛上阅读了很多内容,并试图从google中找到一些结果。可悲的是,我发现的所有东西在我的情况下都不起作用。
我在Linux x86上工作,安装了Git1.9。
我可以从我的服务器"git clone“一个存储库并在其中工作。
例如,我在其中使用"touch testfile“来创建一个新文件。现在我将"git commit“这个文件。
在这一步之后,我"git push“它,然后我得到错误代码。
我在其他文章中发现,这个问题在git2.3中已经解决了,在存储库的配置文件中更改"receive.denyCurrentBranch“的值应该会很有帮助。有帮助的值应为:refuse、updateInstead和ignore
我尝试了所有的方法,错误总是相同的。
在服务器上,配置值列表:
[receive]
denyCurrentBranch = refuse和"git branch“
*master在客户端上,"git status“是:
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)所以,这个错误随时都会出现,我还不知道如何修复它。
如何避免该错误消息?
发布于 2017-06-07 15:38:37
一般的最佳实践是在服务器上创建一个 (git init --bare或convert your existing repo to a bare one),克隆它,添加并提交新文件,然后推送。
该推送不会有您所描述的错误消息。
请注意,任何允许推送到非裸repo的功能(2.3 receive.denyCurrentBranch updateInstead或2.4 push-to-deploy)在Git1.9中都不存在。
发布于 2017-06-07 15:54:09
正如git消息所提示的那样,不推荐使用'receive.denyCurrentBranch‘。
我们通常通过git使用远程存储库和本地存储库进行版本控制。远程存储库是git真正进行版本控制的地方。通常情况下,远程存储库是空的。
因此,推荐的方法是通过git clone <URL of repo> --bare将远程存储库转换为服务器中的裸存储,并将其视为远程存储库,现在将其作为远程存储库工作。
现在,您可以克隆上面的纯存储库并提交/推送到它。
https://stackoverflow.com/questions/44406360
复制相似问题