Push origin master error on new repository

I just started using git with github. I followed their instructions and ran into errors on the last step. I'm checking in an existing directory that isn't currently source-controlled (project about a week old). Other than that, my use case should be pretty run of the mill.

Here's what's happening:

$ git push origin master
error: src refspec master does not match any.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to 'git@github.com:{username}/{projectname}.git'

Github's instructions:

Global setup:

  Download and install Git
  git config --global user.name "Your Name"
  git config --global user.email {username}@gmail.com

Next steps:

  mkdir projectname
  cd projectname
  git init
  touch README
  git add README
  git commit -m 'first commit'
  git remote add origin git@github.com:{username}/{projectname}.git
  git push origin master

The error message leads to the conclusion that you do not have a master branch in your local repository. Either push your main development branch ( git push origin my-local-master:master which will rename it to master on github) or make a commit first. You can not push a completely empty repository.


我遇到了同样的问题,然后把自己打入脑海,因为我实际上并没有添加我的项目文件。

git add -A
git commit -am "message"
git push origin master

I had the same issue. I deleted the .git folder then followed the following commands

  • $ git init
  • $ git add .
  • $ git remote add origin git@gitorious.org:project/project.git
  • $ git commit -m "Initial version"
  • $ git push origin master
  • 链接地址: http://www.djcxy.com/p/7898.html

    上一篇: git仅添加修改的更改并忽略未跟踪的文件

    下一篇: 在新存储库上推送原点主控错误