Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Push to Heroku denied - "failed to push some refs to 'heroku"

I should start by saying I'm totally new to Heroku, and it's all looking pretty to foreign to me right now.

Anyway, I've done the Heroku getting started tutorial, uploading a clone git repo, and this works fine.

I'm now trying to accomplish this with some of my own code, but struggling.

  1. First, I go to my app directory in bash.
  2. Then I run heroku create. This is successful.
  3. I then run git push heroku master as instructed in the tutorial, and I receive the following errors:

error: src refspec master does not match any.

error: failed to push some refs to 'heroku'

Would appreciate if someone can explain what I am missing here? Thanks in advance.

like image 904
Paulos3000 Avatar asked Oct 30 '16 16:10

Paulos3000


Video Answer


2 Answers

It seems that you have not initiated your master branch properly. Have you commited your files? Try (assuming you are on master branch):

git add .
git commit -m "First commit"
git push heroku master:master

Another, more direct approach, is to push the HEAD:

git push heroku HEAD:master
like image 110
andresk Avatar answered Oct 19 '22 16:10

andresk


If you're getting this: error: src refspec master does not match any when attempting to push to heroku master, then you might have to change

git push heroku master to git push heroku main.

(Assuming this project already existed and you had previously pushed it to heroku master).

This is due to a recent update made to git where the term master was changed to main. I had the same issue and this worked for my case.

like image 24
Jesse G Avatar answered Oct 19 '22 18:10

Jesse G