想了解错误的原因:src refspec master不匹配任何。错误:未能将某些引用推送到' https://github.com/xyz.git''

时间:2018-05-02 11:34:14

标签: git github version-control

尝试为网页添加版本控制,之前已经为各种项目使用过git,从未遇到过这个错误:

error: src refspec master does not match any.
error: failed to push some refs to 'https://github.com/aman-tugnawat/MangoDevelopersWebpage.git'

在这些链接中查看了这些解决方案,但没有任何进展。

https://stackoverflow.com/a/7543112/4382835

src refspec master does not match any when pushing commits in git

我想的可能原因: enter image description here

仍然试图理解Github要求跳过初始化README.md的步骤。

完全遵循这个序列:

git init
echo "# MangoDevelopersWebpage" >> README.md
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/aman-tugnawat/MangoDevelopersWebpage.git
git push origin master

想要了解发生的事情而不是代码。

3 个答案:

答案 0 :(得分:1)

您是否检查了是否正确初始化了user.email,user.name之类的全局变量? 对我来说很好。

首先您可以检查:

you@yourPC MINGW64 ~/your-file(master)
$ git config --list

如果有任何问题,请执行以下操作

第1步:

you@yourPC MINGW64 ~/your-file(master)
$ git init
Reinitialized existing Git repository in C:yourPath/your-repo

步骤2:

you@yourPC MINGW64 ~/your-file(master)
$ git add .

步骤3:

you@yourPC MINGW64 ~/your-file(master)
$ git commit -m "second commit"

第4步:

you@yourPC MINGW64 ~/your-file(master)
$ git config --global user.name "Your Name"

第5步:

you@yourPC MINGW64 ~/your-file(master)
$  git config --global user.email you@example.com

第6步:

you@yourPC MINGW64 ~/your-file(master)
$  git push origin master

答案 1 :(得分:0)

理解

  

为什么Github建议在GitHub上创建一个已经存在的本地仓库到新的远程仓库时不要生成README.md?

因为这需要Map<String, BigDecimal> 合并本地和远程回购,这对初学者来说可能很难理解。

通过强行删除README.md来解决问题

git pull

然后

git rm README.md -f

在此处详细了解:git commit origin master https://git-scm.com/docs/git-merge

答案 2 :(得分:0)

我有同样的错误

当您第一次连接github或类似的东西时

您需要配置

我通过git GUI来解决

gitGUI希望我连接并解决问题

  1. 转到您的项目文件夹 project forlder git GUI
  2. 在此处打开Git GUI
  3. 从应用程序的主栏中选择远程 add remote by git gui
  4. 将github中新存储库中的URL复制到此表单中 copy git https url paste it in GIT GUI
  5. 然后阶段改变
  6. 然后提交他们
  7. 然后推送
  8. 然后打开提示,提示用户通过