可能重复:
Git push error '[remote rejected] master -> master (branch is currently checked out)'
我将安装一个自己的查看器(一个git web存储库查看器,旨在轻松设置和升级,轻松依赖,轻松使用),我的git和当前工作正常,但我使用起来很麻烦自己的git。之前我只使用github作为服务。现在,在我自己的网站空间上,我们可以安装git并创建它。但是如果我在源代码上推送我的新更改,我会得到以下消息。在我发送提交之前,将文件添加到repo中;但是对主人的推动是不可能的;只有以下消息就是答案。
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'.
答案 0 :(得分:1)
如果您在自己的服务器上设置了一个git存储库,并希望将其用作推送/拉出的中央存储库,那么它应该是一个裸存储库,而不是普通存储库。
(裸存储库没有检出分支。)
您使用以下命令创建一个裸存储库:
git clone --bare
或可能:
git init --bare