解决“src refspec master does not match anyerror: failed to push some
一、解决"error: src refspec master does not match anyerror: failed to push some refs to”问题描述
"error: src refspec master does not match anyerror: failed to push some refs to”
push 过程中如果远端分支名不同于当地分支名时,则需要将两边名称都写上。
不然会报错找不到。
解决方案
1. 思路
git push origin [当地分支名:远端分支名]
远程分支名称分两种情况:Github和Gitee。
Github远程分支默认为:main。
Gitee远程分支默认为:master。
如图所示:
(1)Github:
https://i-blog.csdnimg.cn/direct/eaa51f13a57b42ae9b134692c5482202.png
(2)Gitee:
https://i-blog.csdnimg.cn/direct/4de3067bff4c43d3bfbaf08c34734bff.png
2. 具体操作
git push origin [当地分支名:远端分支名]
检察当地分支名:
git branch
我的当地分支名为:main
https://i-blog.csdnimg.cn/direct/b75ce1cb83c240a4bfe0dec4b7c11f61.png
(1)Github命令
git push origin main:main
(2)Gitee命令
git push origin main:master
问题得到解决。
二、用git将项目文件push到远程仓库
1. 检察当前远程连接情况
git remote -v
2. 如果之前的远程连接已经存在的话,使用命令删除
git remote rm origin
3. 初始化一个git当地仓库
git init
4. 将现在所在目录下的全部文件举行缓存
git add .
5. 添加远程连接
git remote add origin 【git网址】
【git网址】:可以直接到gitlab clone http复制粘贴
GitHub:
https://i-blog.csdnimg.cn/direct/6c9ae6fbea7e4398a0fc2b235ee1c3eb.png
Gitee:
https://i-blog.csdnimg.cn/direct/a39ea8430b6740e9b62049f0461af04d.png
https://i-blog.csdnimg.cn/direct/910098d6f9774493a04ea1ca311156d0.png
6. 给的本次更新添加一个tag"XXX"
XXX可以自定义
git commit -m "XXX"
7. 给当地创建一个"main"分支
git branch
main 8. 检察当地分支名称
git branch
https://i-blog.csdnimg.cn/direct/b75ce1cb83c240a4bfe0dec4b7c11f61.png
9. 将当地分支push到远程服务器
问题
"error: src refspec master does not match anyerror: failed to push some refs to”
push 过程中如果远端分支名不同于当地分支名时,则需要将两边名称都写上。
不然会报错找不到。
解决方案
1. 思路
git push origin [当地分支名:远端分支名]
远程分支名称分两种情况:Github和Gitee。
Github远程分支默认为:main。
Gitee远程分支默认为:master。
如图所示:
(1)Github:
https://i-blog.csdnimg.cn/direct/eaa51f13a57b42ae9b134692c5482202.png
(2)Gitee:
https://i-blog.csdnimg.cn/direct/4de3067bff4c43d3bfbaf08c34734bff.png
2. 具体操作
git push origin [当地分支名:远端分支名]
检察当地分支名:
git branch
(1)Github命令
git push origin main:main
(2)Gitee命令
git push origin main:master
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页:
[1]