git首次推送失败
在使用GitPush代码到数据仓库时,提示如下错误:
remote:error:refusingtoupdatecheckedoutbranch:refs/heads/master
remote:error:Bydefault,updatingthecurrentbranchinanon-barerepository
remote:error:isdenied,becauseitwillmaketheindexandworktreeinconsistent
remote:error:withwhatyoupushed,andwillrequire'gitreset--hard'tomatch
remote:error:theworktreetoHEAD.
remote:error:
remote:error:Youcanset'receive.denyCurrentBranch'configurationvariableto
remote:error:'ignore'or'warn'intheremoterepositorytoallowpushinginto
remote:error:itscurrentbranch;however,thisisnotrecommendedunlessyou
remote:error:arrangedtoupdateitsworktreetomatchwhatyoupushedinsome
remote:error:otherway.
remote:error:
remote:error:Tosquelchthismessageandstillkeepthedefaultbehaviour,set
remote:error:'receive.denyCurrentBranch'configurationvariableto'refuse'.
[email protected]:/var/git.server/.../web
![remoterejected]master->master(branchiscurrentlycheckedout)
error:failedtopushsomerefsto'[email protected]:/var/git.server/.../web'
解决办法:
这是由于git默认拒绝了push操作,需要进行设置,修改.git/config文件后面添加如下代码:
[receive]
denyCurrentBranch=ignore
我在git的初始化仓库的.git目录中的config修改加入以上配置并没有成功
而在git仓库的.git目录执行gitconfigreceive.denyCurrentBranchignore之后
本地能成功推送到远程
具体原因不清楚,难道不应该是改仓库的config文件