error: src refspec master does not match any error: failed to push some refs to ‘github.com:Lydever/

本地关联github远程仓库,本地在 pull or push的时候报错:
error: src refspec master does not match any error: failed to push some refs to 'github.com:Lydever/typescript-projects.git'

原因

本地分支与远程分支不一致导致,2020年起,github上创建的仓库默认分支为main 而不再是master,而本地git 初始化后默认分支为master
在这里插入图片描述

解决

重命名分支,使分支名称一致:
master 重命名为main

git branch -m oldBranchName newBranchName

在这里插入图片描述
这个时候在pull或者push就不会报错了。
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_43853746/article/details/122387056