I'm hosting on Heroku. When I push:
git push master Heroku
I get the error:
error: src refspec master does not match any.
error: failed to push some refs to '[email protected]: etc ...'
I'm hosting on Heroku. When I push:
git push master Heroku
I get the error:
error: src refspec master does not match any.
error: failed to push some refs to '[email protected]: etc ...'
This is work for me:-
git push heroku HEAD:master
git push <remote> <local ref>:<remote branch>
syntax) and the OP's version doesn't. –
Prosecutor master
as second parameter to git push
is the remote default branch in heroku and has to be set in some cases like in this src refspec
? The local branch is the one that you checkout
ed and can be different from master
. –
Runt I have experienced the problem. I solved this problem like this
make file whatever
commit
push
$ touch readme
$ git add .
$ git commit -m "init"
$ git push heroku master
I don't know why.
git push heroku main
with this solution worked for me –
Acquit 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 [email protected]:yourproject.git (fetch)
Heroku [email protected]:yourproject.git (push)
git commit -m "Initial commit"
–
Sill 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.
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.
This is a late answer, but might help someone.
instead of this:
git push master Heroku
try:
git push heroku master
actually, i needed to create a file, otherwise commit was empty.
touch readme.md
git commit -m dummy --allow-empty
instead of changing files –
Wehrle Starting Oct. 1st, 2020 Github defaults to "main" instead of "master" as the default branch name when you create a new repository. If you've followed all the usual steps then take a look at your current branches ("git branch") and make sure this isn't tripping you up (like it did me).
https://www.zdnet.com/article/github-to-replace-master-with-main-starting-next-month/
This worked for me.
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
if you are writing ->
"git push master Heroku"
and getting error like->
error: src refspec master does not match any. error: failed to push some refs to '[email protected]: etc'
then first type in hyper->
git commit -m 'Initial commit'
and then if there is an error like
email ,name is not found or something like that
then it might be possible that you could'nt sign in heroku page.
first write type in hyper commond line or whatever cmd line you are using
git config --global user.email "yourgmail address"
then hit enter then type
git config --global user.name "Your Name"
then it will work fine. if you want to check that it is working fine then type
git commit -m 'initial commit'
it will take sometime and then write code
git push heroku master
-------------------------Now everything is solved-TADADAAAA-------------------------- Note-Please write your email address and username in above code...
Probably you are not on the branch master in your local machine.
checkout to master
branch/ or main
branch
and then do
git push heroku master
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.
Come in late but in my case:
git push [email protected]:appname.git master
did the trick for me! With appname being the name of your heroku app
First push your changes to the remote branch before pushing to heroku
git push origin master
git push heroku master
If you want to push a branch which is not the master branch to heroku
git push origin development_branch
git push heroku development_branch:master
For me I need to commit files first
git commit -m "First commit adding files"
then
git push heroku master
Also check whether, is your master branch is main
then you need to use
git push heroku main
Similarly, if you want to push any of your branch which is not a master then use
git push heroku <branch_name>
heroku git:remote -a <APP-NAME>
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
The error on my terminal "testpry git:(ft-heroku-deployment-170679745) git push heroku master error: src refspec master does not match any. error: failed to push some refs to 'https://git.heroku.com/guarded-taiga-41995.git'"
Solution: You need to check the name of the branch you are working on. In this case, it is "ft-heroku-deployment-170679745"
The right push command is $ git push heroku ft-heroku-deployment-170679745
I experienced the same issue.
For me the problem occurred because I hadn't signed into git correctly.
Before you can push code to the master branch, you must have first made your initial commit with the command git commit -m "My first commit"
. You may have gotten this response when trying to do that (like I got):
git: fatal unable to auto-detect email address (got "some wrong email").
If that was the response you got, you must now enter your desired git email and username with the commands:
git config --global user.email "[email protected]"
git config --global user.name "Your Username"
After you've done that, try the push command again
git push heroku master
It should work now.
For me the problem was having two lockfiles package-lock.json
and yarn.lock
. Deleting one of them solved the problem. Here is the error message:
! Two different lockfiles found: package-lock.json and yarn.lock
Both npm and yarn have created lockfiles for this application,
but only one can be used to install dependencies. Installing
dependencies using the wrong package manager can result in missing
packages or subtle bugs in production.
- To use npm to install your application's dependencies please delete
the yarn.lock file.
$ git rm yarn.lock
- To use yarn to install your application's dependences please delete
the package-lock.json file.
$ git rm package-lock.json
just make sure you are pushing the same app name as in Heroku.
if the above solutions did not work check the hidden .git folder. in .git folder check for file packed-refs it should have a hash key referencing to refs/remotes/heroku/main if this is not there then. you can follow below steps
to get list of heroku apps. you can run below cmd heroku apps
Follow this steps:
$ git init
$ git add .
$ git commit -m "init"
$ git branch -M main
$ git push heroku main
heroku https://git.heroku.com/yourapp.git (fetch) heroku https://git.heroku.com/yourapp.git (push)
if there is none then set the remote - git remote add heroku [email protected]:MyApp.git (in old git versions ) or heroku git:remote -a example-app (in new version of git)
git push heroku master (old git) git push heroku main (new git )
I experienced this issue after pushing a copy of my local repository to a GitHub repo.
Prior to that, git push heroku master
from my local repo was working fine to deploy to Heroku.
After pushing to GitHub however, git push heroku master
began giving the error: src refspec master does not match any
message, and I had to git push heroku main
to successfully deploy.
Apparently pushing a copy to GitHub changed the branch name of the local repo from master
to main
.
If you are here in 2024, chances are that you are not connected to the heroku branch, take these easy steps to deploy:
heroku create -a example-app
git remote -v
you will see you heroku git branch heroku https://git.heroku.com/example-app.git (fetch) heroku https://git.heroku.com/example-app.git (push)
this is the most important!! set the remote branch
set git remote heroku to https://git.heroku.com/example-app.git
then push again
git push heroku main
i hope this helped someone, and you can check out the official documentation here: heroku staging
© 2022 - 2024 — McMap. All rights reserved.
commit
afteradding
? – Gaskellgit config --global
. – Beckergit push heroku main
maybe required – Acquit