我在使用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'.
因此,我的第一步是在这个论坛上阅读很多帖子,并尝试从谷歌中找到一些结果。可惜我发现没有一个适用于我的情况。
我正在使用Linux x86,并安装了Git 1.9。
我可以从服务器上"git clone
"一个仓库并在其中工作。
例如,我在里面"touch testfile
"来创建一个新文件。 现在我将"git commit
"这个文件。
完成这个步骤后我 "git push
",然后出现了错误代码。
我在其他文章中发现问题已经在Git 2.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)
因此,该错误可能随时出现,我目前不知道如何修复它。
我该如何避免这个错误提示?