git 推送到 Heroku 时无法从远程存储库读取(Rails 教程 5)

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

Could not read from remote repository when pushing to Heroku (Rails Tutorial 5)

ruby-on-railsgitheroku

提问by jeffbenner

I pushed my chapter 5 version of Sample_App to git, and then when I 'git push heroku' I get:

我将 Sample_App 的第 5 章版本推送到 git,然后当我 'git push heroku' 时,我得到:

warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:

git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

git config --global push.default simple

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)


!  No such app as sample_app.

fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I have read through some of the similar stackoverflow questions, and so I know to look at the 'git remote -v':

我已经阅读了一些类似的 stackoverflow 问题,所以我知道要查看“git remote -v”:

heroku  [email protected]:sample_app.git (fetch)
heroku  [email protected]:sample_app.git (push)
origin  [email protected]:jeffbenner/sample_app.git (fetch)
origin  [email protected]:jeffbenner/sample_app.git (push)

I have tried removing heroku and re-pushing - I get the same error message.

我尝试删除 heroku 并重新推送 - 我收到相同的错误消息。

I looked at 'git config -l':

我看着'git config -l':

user.name=jeffbenner
[email protected]
alias.co=checkout
push.defaults=simple
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=false
[email protected]:jeffbenner/sample_app.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
[email protected]:sample_app.git
remote.heroku.fetch=+refs/heads/*:refs/remotes/heroku/*

I cannot figure out why I cannot push to Heroku. I have re-logged into both my Github and Heroku accounts through the CLI. Any direction would be much appreciated.

我不明白为什么我不能推送到 Heroku。我已经通过 CLI 重新登录了我的 Github 和 Heroku 帐户。任何方向将不胜感激。

采纳答案by fontno

Did you try to specify the branch that you are pushing. Try git push heroku master. You can read about the warning in the docs. Let me know if it worked

您是否尝试指定要推送的分支。试试git push heroku master。您可以阅读文档中警告。让我知道它是否有效

Edit

编辑

I would just start over all together and create a new Heroku address. Follow these steps in order

我会一起重新开始并创建一个新的 Heroku 地址。请按顺序执行以下步骤

First in your Gemfilecreate these groups

首先在您Gemfile创建这些组

group :development do
  gem 'sqlite3'
end

group :production do
  gem 'pg'
end

Important, make sure you are in the rootof your projectand make sure you run bundle installlike this

重要的是,确保你在你的身边rootproject并确保你bundle install像这样运行

bundle install --without production

now git add .then git commit -m 'your commit message'

现在git add .然后git commit -m 'your commit message'

now run heroku loginfrom the command line

现在运行heroku login在命令行

now run heroku create

现在运行 heroku create

then git push heroku master

然后 git push heroku master

finally heroku openwill open your app in your browser

最后heroku open会在浏览器中打开你的应用

If all of this doesn't work then move the app into a new directoy and start all over by first git init, git add .and git commit -m 'first commit in new location'and follow the steps above starting with heroku login

如果所有的这不起作用然后将应用到一个新的directoy和第一从头再来git initgit add .git commit -m 'first commit in new location'并按照上面开始的步骤heroku login

Note that heroku and github both use git but are independent entities. If you can push your code to github and you see it on github, then you should be able to push your code to heroku with no problem. If not you may be doing something wrong with git locally on your computer.

请注意,heroku 和 github 都使用 git,但它们是独立的实体。如果您可以将代码推送到 github 并在 github 上看到它,那么您应该可以毫无问题地将代码推送到 heroku。如果不是,您可能在您的计算机上本地使用 git 做错了什么。

回答by Mathieu

I just came across the same problem. I did the following:

我刚刚遇到了同样的问题。我做了以下事情:

cd .git
vim config

removed all lines referencing Heroku

删除了所有引用 Heroku 的行

cd ..
heroku create
git push heroku master

... And voila, it worked.

...... 瞧,它奏效了。

Hoped this helps.

希望这会有所帮助。

回答by luigi7up

I had no idea why, but stopping running foremanin my local machine allowed a push to heroku master... Could be coincidence :|

我不知道为什么,但是停止在我的本地机器上运行foreman允许推送到 heroku master ......可能是巧合:|