Git error:'fatal: Couldn't find remote ref master'

本文選取并翻譯自:https://saywebsolutions.com/blog/git-github-error-fatal-couldnt-find-remote-ref-master

如果出現(xiàn)該錯誤提示,可能是因?yàn)槭褂昧伺f命令:

   git pull origin master

master現(xiàn)在被認(rèn)為是有種族歧視的,github將其換成了main,所以現(xiàn)在使用pull可以寫為:

   git pull origin main

如需要將已有repos的master換為main,可依照以下步驟:

  • 1-重命名本地分支:

     git branch -m master main
    
  • 2-重命名遠(yuǎn)程分支

     git checkout main
    
     git push -u origin main
    
  • 3-刪除遠(yuǎn)程分支master

     git push origin --delete master
    
  • 4-告知團(tuán)隊(duì)中的其他人更新他們的本地庫,方法如下:

     # Switch to "master" branch
    
     git checkout master
    
     # Rename "master" branch to "main"
    
     git branch -m master main
    
     # Get latest commits and branches from remote
    
     git fetch
    
     # Remove existing connection with "master"
    
     git branch --unset-upstream
    
     # Create connection with new "main" branch
    
     git branch -u origin/main
    
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

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

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