Git进行push时报错

用TortoiseGit进行push时报如下错:

git.exepush--progress"origin"master:master

Countingobjects:6,done.

Deltacompressionusingupto4threads.

Compressingobjects:100%(3/3),done.

Writingobjects:100%(3/3),528bytes|0bytes/s,done.

Total3(delta0),reused0(delta0)

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'.

ToD:\test

![remoterejected]master->master(branchiscurrentlycheckedout)

error:failedtopushsomerefsto'D:\test'

解决方案:

1、用TortoiseGit创建仓库时,选择MakeitBare.

2、在.git/config中添加如下代码:

[receive]

denyCurrentBranch=ignore

相关推荐