git 推送到 Heroku 被拒绝 - “未能将一些引用推送到 'heroku”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40331282/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 12:23:46  来源:igfitidea点击:

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

githerokugithubpush

提问by Paulos3000

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

我应该首先说我对 Heroku 完全陌生,现在对我来说这一切看起来都很陌生。

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

无论如何,我已经完成了 Heroku 入门教程,上传了一个克隆 git 存储库,这很好用。

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 masteras instructed in the tutorial, and I receive the following errors:
  1. 首先,我在 bash 中转到我的应用程序目录。
  2. 然后我跑heroku create。这是成功的。
  3. 然后我git push heroku master按照教程中的说明运行,我收到以下错误:

error: src refspec master does not match any.

error: src refspec master does not match any.

error: failed to push some refs to 'heroku'

error: failed to push some refs to 'heroku'

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

如果有人能解释我在这里缺少什么,我会很感激吗?提前致谢。

回答by andresk

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

看来你没有正确启动你的主分支。你提交文件了吗?尝试(假设您在 master 分支上):

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

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

另一种更直接的方法是推送 HEAD:

git push heroku HEAD:master

回答by AbandonedEngineer

I was working on this for the past 3 hours and now i get it clearly. all you need to do is init with whatever project and all i did it "npm init"

过去 3 个小时我一直在研究这个,现在我明白了。您需要做的就是使用任何项目进行初始化,而我所做的一切都是“npm init”