git push error: src refspec main does not match any
程序员文章站
2023-12-30 17:39:58
...
因为git版本的问题,本地默认分支为master, 远程默认分支为main
执行以下操作初始化仓库时遇错:
git init
git remote add origin [email protected]:
git add.
git commit -m 'test'
git push
第一个问题:
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)
Everything up-to-date
首先git版本的问题,push.default matching 将本地push的文件提交到远程的所有分支上面
push.default simple 将本地push的文件提交到pull下来的分支
建立远程仓库时创建了readme文件,需要先pull下来
第二个问题:
error: src refspec main does not match any.
远程没有master分支,即本地与远程没有名称相同的分支,所以上传失败。
解决办法,在本地建立main分支,或者在远程建立master分支。