[Linux] Git: push 出错的解决 master -> master (branc

<p>在使用Git Push代码到数据仓库时,提示如下错误:</p><pre class="brush:bash;toolbar:false">[remoterejected]master-&gt;master(branchiscurrentlycheckedout) remote:error:refusingtoupdatecheckedoutbranch:refs/heads/master remote:error:Bydefault,updatingthecurrentbranchinanon-barerepository remote:error:isdenied,becauseitwillmaketheindexandworktreeinconsistent remote:error:withwhatyoupushed,andwillrequire&#39;gitreset--hard&#39;tomatch remote:error:theworktreetoHEAD. remote:error: remote:error:Youcanset&#39;receive.denyCurrentBranch&#39;configurationvariableto remote:error:&#39;ignore&#39;or&#39;warn&#39;intheremoterepositorytoallowpushinginto remote:error:itscurrentbranch;however,thisisnotrecommendedunlessyou remote:error:arrangedtoupdateitsworktreetomatchwhatyoupushedinsome remote:error:otherway. remote:error: remote:error:Tosquelchthismessageandstillkeepthedefaultbehaviour,set remote:error:&#39;receive.denyCurrentBranch&#39;configurationvariableto&#39;refuse&#39;. Togit@192.168.1.X:/var/git.server/.../web ![remoterejected]master-&gt;master(branchiscurrentlycheckedout) error:failedtopushsomerefsto&#39;git@192.168.1.X:/var/git.server/.../web&#39;</pre><p>这是由于git默认拒绝了push操作,需要进行设置,修改.git/config添加如下代码:</p><pre class="brush:bash;toolbar:false">[receive] denyCurrentBranch=ignore</pre><p></p><p>在初始化远程仓库时最好使用 git --bare init 而不要使用:git init</p><p> 如果使用了git init初始化,则远程仓库的目录下,也包含work tree,当本地仓库向远程仓库push时, 如果远程仓库正在push的分支上(如果当时不在push的分支,就没有问题), 那么push后的结果不会反应在work tree上, 也即在远程仓库的目录下对应的文件还是之前的内容,必须得使用git reset --hard才能看到push后的内容.</p>
RangeTime:0.007983s
RangeMem:205.64 KB
返回顶部 留言