git 提交代碼時(shí) remote: error:

在本地提交代碼的時(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即可。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • **2014真題Directions:Read the following text. Choose the be...
    又是夜半驚坐起閱讀 11,123評論 0 23
  • 打開豆瓣,收到影評被點(diǎn)贊的通知,寫的時(shí)候覺得很爛,但是觀后的感覺強(qiáng)烈的快溢出來,只能用拙劣的文筆寫下感受,時(shí)隔多日...
    大海說灑灑水閱讀 318評論 2 1
  • 一、問題:在Android啟動(dòng)后會在新進(jìn)程里創(chuàng)建一個(gè)主線程,也叫UI線程(非線程安全)這個(gè)線程主要負(fù)責(zé)監(jiān)聽屏幕點(diǎn)擊...
    wingjay閱讀 5,012評論 9 39
  • 你是一封信 來自不期而至的遠(yuǎn)方 我知道 終有一天 你會走過 我荒草叢生的墓地 用你好聽的聲音 讀那行 歪歪扭扭的墓...
    毛毛不會飛閱讀 249評論 0 0

友情鏈接更多精彩內(nèi)容