本文选取并翻译自:https://saywebsolutions.com/blog/git-github-error-fatal-couldnt-find-remote-ref-master
如果出现该错误提示,可能是因为使用了旧命令:
git pull origin master
master现在被认为是有种族歧视的,github将其换成了main
,所以现在使用pull可以写为:
git pull origin main
如需要将已有repos的master
换为main
,可依照以下步骤:
-
1-重命名本地分支:
git branch -m master main
-
2-重命名远程分支
git checkout main git push -u origin main
-
3-删除远程分支
master
git push origin --delete master
-
4-告知团队中的其他人更新他们的本地库,方法如下:
# 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