I want make push and get error: src refspec master

2019-01-17 10:30发布

I'm hosting on Heroku. I want to make a push:

git push master Heroku

I gets the message:

error: src refspec master does not match any.
error: failed to push some refs to 'git@heroku.com: etc ...'

10条回答
可以哭但决不认输i
2楼-- · 2019-01-17 10:56

This is a late answer, but might help someone.

instead of this:

git push master Heroku

try:

git push heroku master
查看更多
爷、活的狠高调
3楼-- · 2019-01-17 10:58

Come in late but in my case:

git push git@heroku.com:appname.git master

did the trick for me! With appname being the name of your heroku app

查看更多
手持菜刀,她持情操
4楼-- · 2019-01-17 11:03

In my case, this happened because I had nothing to push. I had forgotten to do a "git add" first. As soon as I did a "git add" then "git commit" for actual content, the push worked fine.

查看更多
一纸荒年 Trace。
5楼-- · 2019-01-17 11:04

actually, i needed to create a file, otherwise commit was empty.

touch readme.md
查看更多
Viruses.
6楼-- · 2019-01-17 11:07

I came here after following the step-by-step guide of heroku. To me the problem was solved after creating minimum a file in the repository, committing it and then pushing to heroku again.

查看更多
甜甜的少女心
7楼-- · 2019-01-17 11:09

At first glance it looks like you have got your master and Heroku parameters round the wrong way because the first parameter to git push should be the name of the remote repository, the second is refspec (normally a branch). You are more likely to have a branch called master and a remote called Heroku. But I would expect you to get a different error message if that were the case, something like:

fatal: 'master' does not appear to be a git repository
fatal: Could not read from remote repository.

The error message you are seeing implies that there is no local master branch. That would be the case if you haven't made any commits yet because git doesn't create the branch until the first commit. You can check this by running:

git show-ref

You should see a line containing refs/heads/master if you have a master branch. If not then try running:

git commit -m 'Initial commit'

You can also find out what remotes you have available with:

git remote -v

If you have a remote called Heroku you should see something like:

Heroku  git@heroku.youraccount:yourproject.git (fetch)
Heroku  git@heroku.youraccount:yourproject.git (push)
查看更多
登录 后发表回答