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'.

你可能感兴趣的:(git)