git 提交代码时 remote: error:


 

在本地提交代码的时候会出现一堆报错git

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’.服务器

根据上面所报的信息,它的意思就是默认状况下,git不容许用push操做更新non-bare的仓库,由于这样的操做会致使remote仓库的索引 (index)和工做树(work tree)与你push的不一致,此时须要经过‘git reset --hard’操做来使得工做树与HEAD索引相匹配。 能够经过在remote端,设置git的配置文件(.git/config,在服务器端),在其中添加以下内容:less

[receive]ui

denyCurrentBranch = falsethis

这样就能够经过git push提交本身的稳定更新,要想在push后在remote端看到更新的效果,执行git reset --hard便可。blog

相关文章
相关标签/搜索