首页 > 其他 > 详细

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

时间:2020-12-31 09:43:29      阅读:879      评论:0      收藏:0      [点我收藏+]

本文选取并翻译自: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
 

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

原文:https://www.cnblogs.com/mygh/p/14214224.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!