git 我想要推送并得到错误:src refspec master 不匹配任何
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26595874/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
I want make push and get error: src refspec master does not match any
提问by Mark
I'm hosting on Heroku. I want to make a push:
我在 Heroku 上托管。我想推动:
git push master Heroku
I gets the message:
我收到消息:
error: src refspec master does not match any.
error: failed to push some refs to '[email protected]: etc ...'
回答by vineet
This is work for me:-
这对我来说是工作:-
git push heroku HEAD:master
回答by jijijijiji
I have expericed the problem you have. I solved this problem like this
你遇到的问题我也遇到过。我这样解决了这个问题
- make file whatever
- commit
push
$ touch readme $ git add . $ git commit -m "init" $ git push heroku master
- 随便制作文件
- 犯罪
推
$ touch readme $ git add . $ git commit -m "init" $ git push heroku master
I don't know why.
我不知道为什么。
回答by Steve
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:
乍一看,您的master
和Heroku
参数似乎是错误的,因为第一个参数 togit push
应该是远程存储库的名称,第二个是 refspec (通常是一个分支)。您更有可能拥有一个名为 的分支master
和一个名为 的远程Heroku
。但如果是这种情况,我希望您收到不同的错误消息,例如:
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:
您看到的错误消息暗示没有本地master
分支。如果您还没有进行任何提交,就会出现这种情况,因为 git 在第一次提交之前不会创建分支。您可以通过运行来检查:
git show-ref
You should see a line containing refs/heads/master
if you have a master branch. If not then try running:
您应该看到一行包含refs/heads/master
是否有主分支。如果没有,请尝试运行:
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 的遥控器,您应该会看到如下内容:
Heroku [email protected]:yourproject.git (fetch)
Heroku [email protected]:yourproject.git (push)
回答by user1515295
I got this error when trying to push to Heroku when I wasn't on my local master branch.
当我不在本地主分支上时尝试推送到 Heroku 时出现此错误。
I resolved it with
我解决了
git push heroku my_branch_name:master
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.
并替换my_branch_name
为我所在的 git 分支的名称。我认为这告诉 Heroku 在 Heroku 的主分支上接收这个本地分支。
回答by Tim Holt
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.
就我而言,发生这种情况是因为我没有什么可推动的。我忘了先做一个“git add”。一旦我对实际内容执行了“git add”然后“git commit”,推送就可以正常工作。
回答by csomakk
actually, i needed to create a file, otherwise commit was empty.
实际上,我需要创建一个文件,否则提交是空的。
touch readme.md
回答by Angel M.
This is a late answer, but might help someone.
这是一个迟到的答案,但可能会帮助某人。
instead of this:
而不是这个:
git push master Heroku
try:
尝试:
git push heroku master
回答by Andy
This worked for me.
这对我有用。
git config --global user.email "[email protected]"
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
git config --global user.name "你的名字"
回答by R01010010
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.
我是按照 heroku 的分步指南来到这里的。对我来说,在存储库中创建最小文件,提交它然后再次推送到 heroku 后,问题得到了解决。
回答by Dave K
Come in late but in my case:
来晚了,但就我而言:
git push [email protected]:appname.git master
git push [email protected]: appname.git master
did the trick for me! With appnamebeing the name of your heroku app
为我做的伎俩!随着应用程序的名字是你的Heroku应用程序的名称