2011-09-11 139 views
-2

可能重复工作:
Git push error '[remote rejected] master -> master (branch is currently checked out)'用自己的git仓库

我将安装自己的浏览器(一个git网库浏览器,旨在易于设置和升级,光在依赖关系上,并且使用起来很舒服),因为我的git和当前工作正常,但是我使用自己的git有很多麻烦。在我只使用github作为服务之前。现在,在我自己的webspace上,我们可以安装git并创建它。但是如果我在源代码上推送新的更改,我会收到后续消息。在我发送提交之前,并将文件添加到回购之前;但对主人的推动是不可思议的;只有以下信息才是答案。

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

我有没有想法你在说什么。这是什么“自己的观众”? – CharlesB

+1

我已更新我的英语不好,希望这有助于。 – bueltge

回答

1

如果你已经建立了自己的服务器上一个Git仓库,并希望使用它作为一个中央资料库,从推/拉,它应该是一个纯仓库,而不是一个正常的。

(纯仓库没有一个分支签出。)

您创建一个纯仓库:

git clone --bare 

或可能:

git init --bare 
+0

喜垫子; WYH?我开发本地化,并将承诺并推送到网络中的中央服务器。裸露的任务是什么?而为什么要在裸露中克隆回购呢?谢谢! – bueltge

+0

@bueltge:呃......为了避免你遇到的问题。推送到非裸露的远程将不会更新检出分支的工作树。这可能会导致数据丢失,这就是为什么你会得到警告 – sehe

+0

git config --bool core.bare true 在远程回购,然后工作正常,谢谢 – bueltge