error: src refspec master does not match any. error: failed to push some refs to ‘‘错误的解决办法

error: src refspec master does not match any

error: failed to push some refs to 'xxx.git'

1.问题描述:

使用如下代码创建本地git仓库:

touch README.md

git init

git add README.md

git commit -m 'first commit'

git remote add origin xxxxxxxxxx.git

git push -u origin master

push至remote端时 发生异常:

error: src refspec master does not match any

error: failed to push some refs to 'xxxxxx.git'

2.解析

检查本地brach情况:

git branch --show-current

main

与remote端 master分支冲突

3.解决方法

将 git push -u origin master 更改为 git push -u origin main

即可将本地项目 正常push至remote端.

运行结果:

Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 228 bytes | 228.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
remote: You are creating a new remote branch, openI will check all files in commit history to find oversize files
remote: . Processing 1 references
remote: Processed 1 references in total
To xxxxx.git
 * [new branch]      main -> main
branch 'main' set up to track 'origin/main'.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值