2014-03-13 62 views
0

我一直在使用git对我的项目进行一些更改。我添加了我更改的文件,然后执行这些更改。当我试图推动更改时,我得到以下结果。有人可以帮助解释我做错了什么吗? 任何帮助将不胜感激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/' 
+0

你不能(默认情况下)推入非裸仓库。用'git init --bare'创建一个裸仓库,然后你可以推送它。 – knittl

+0

@ knittl,你可以,我一直这样做,但不是到当前签出的分支。 –

+0

@JonathanWakely:是的,你是对的。但通常认为在非裸回购中推入任何分支机构并不是一个好习惯。 – knittl

回答

0

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

这意味着你是推到非纯仓库,包含工作树即一个,和你推到分支签出。

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

要解决这个问题,或者在远端使用纯仓库,或登录到远程计算机,并检查了不同的(非主)分支,这样的话你可以把更新master

+0

这是否意味着我需要另一个分支才能推向主?对不起,我不经常使用Git。 – user3122551

+0

将远程转换为裸回购(请参阅http://stackoverflow.com/questions/2816369/git-push-error-remote-rejected-master-master-branch-is-currently-checked)或创建新分支在远程(我经常只是'git co -b tmp'来创建一个新的分支并检查它) –