git添加并提交成功但推送失败

时间:2014-03-13 10:19:19

标签: git push

我一直在使用git对我的项目进行一些更改。我添加了我更改的文件,然后提交了这些更改。当我试图推动变化时,我得到了以下内容。有人可以帮助解释我做错了什么吗? 任何帮助将不胜感激

C:\Users\Ace\Desktop\GitHub\ProjectZero [master]> git push

Warning: Permanently added 'IP ADDRESS' (RSA) to the list of known hosts.    
Counting objects: 11, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (6/6), 599 bytes | 0 bytes/s, done.
Total 6 (delta 4), reused 0 (delta 0)
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'.

To amazon:/var/www/html/ProjectZero/

 ! [remote rejected] master -> master (branch is currently checked out)

error: failed to push some refs to 'amazon:/var/www/html/ProjectZero/'

1 个答案:

答案 0 :(得分:0)

! [remote rejected] master -> master (branch is currently checked out)

这意味着您正在推送到非裸存储库,即包含工作树的存储库,并且会检出您要推送的分支。

这被拒绝了,因为如果某人正在该克隆中的远程机器上工作,那么他们正在处理的分支会突然被神秘地修改。

要解决此问题,请在远程端使用裸存储库,或者登录到远程计算机并签出其他(非主)分支,以便可以将更新推送到master