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

相關文章
相關標籤/搜索