本文選取并翻譯自:https://saywebsolutions.com/blog/git-github-error-fatal-couldnt-find-remote-ref-master
如果出現(xiàn)該錯(cuò)誤提示质欲,可能是因?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