
在本地提交代碼的時(shí)候會出現(xiàn)一堆報(bào)錯(cuò)
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’.
根據(jù)上面所報(bào)的信息,它的意思就是默認(rèn)情況下,git不允許用push操作更新non-bare的倉庫,因?yàn)檫@樣的操作會導(dǎo)致remote倉庫的索引 (index)和工作樹(work tree)與你push的不一致,此時(shí)需要通過‘git reset --hard’操作來使得工作樹與HEAD索引相匹配。 可以通過在remote端,設(shè)置git的配置文件(.git/config,在服務(wù)器端),在其中添加如下內(nèi)容:
[receive]
denyCurrentBranch = false
這樣就可以通過git push提交自己的穩(wěn)定更新,要想在push后在remote端看到更新的效果,執(zhí)行g(shù)it reset --hard即可。