I want make push and get error: src refspec master does not match any

怎甘沉沦 提交于 2019-11-27 00:43:19

问题


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

回答1:


This is work for me:-

git push heroku HEAD:master



回答2:


I have expericed the problem you have. I solved this problem like this

  1. make file whatever
  2. commit
  3. push

    $ touch readme
    
    $ git add .
    
    $ git commit -m "init"
    
    $ git push heroku master
    

I don't know why.




回答3:


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)



回答4:


I got this error when trying to push to Heroku when I wasn't on my local master branch.

I resolved it with

git push heroku my_branch_name:master

and replacing my_branch_name with the name of the git branch I was on. I think this tells Heroku to receive this local branch on Heroku's master branch.




回答5:


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.




回答6:


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

touch readme.md



回答7:


This is a late answer, but might help someone.

instead of this:

git push master Heroku

try:

git push heroku master



回答8:


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.




回答9:


This worked for me.

git config --global user.email "you@example.com"

git config --global user.name "Your Name"




回答10:


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




回答11:


Just adding an answer which is to the point of the question

You are facing this error because Git create master branch only after commit to your local repo. If you just initialize repo then there is no master.

So how do you fix it?

Just add and commit at least one change to your repo and re-run push command. You can add and commit a simple .gitignore file as well likewise stated in other answers



来源:https://stackoverflow.com/questions/26595874/i-want-make-push-and-get-error-src-refspec-master-does-not-match-any

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!