如何链接一个文件夹与现有的Heroku应用程序 [英] How to link a folder with an existing Heroku app

查看:85
本文介绍了如何链接一个文件夹与现有的Heroku应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在GitHub上有一个现有的Rails应用程序,并部署在Heroku上。我试图建立一个新的开发机器,并从我的GitHub仓库克隆了这个项目。不过,我很困惑如何将此文件夹链接到Heroku。最初,我使用了 heroku create 命令,但显然这次我不想这样做,因为它会创建另一个Heroku实例。

解决方案

Heroku 根据 heroku git remote(以及其他一些选项,请参阅下面的更新)。要在您当前的存储库中将Heroku远程添加为远程,请使用以下命令:

  git remote add heroku git @ heroku。 com:project.git 

其中项目是Heroku项目的名称(与 project.heroku.com 子域相同)。一旦你这样做了,你可以使用 heroku xxxx 命令(假设你有 Heroku Toolbelt ),并可以像往常一样通过 git push heroku master 推送到Heroku。作为一个捷径,如果你使用的是命令行工具,你可以输入:

  heroku git:remote -a project 

其中,项目是你的Heroku项目(感谢, Panic上校)。您可以通过传递 -r remote_name 来为Git指定任何远程命令。

[更新]

正如评论中的Ben所提到的,远程并不需要命名为 heroku 宝石命令的工作。我查看了来源,并且它出现了像这样工作:


  1. 如果您通过 - app 指定应用程序名称,选项(例如 heroku info --app myapp ),它将使用该应用程序。
  2. 如果您指定了Git remote通过 - 远程选项(例如 heroku info --remote production ),它将使用如果您在Git配置文件中指定了没有选项并且 heroku.remote 设置了,它将使用与该远程相关联的应用程序(例如,在存储库中使用 git config heroku.remote production 将默认远程设置为production,Heroku将运行 git config heroku.remote 可读取此设置的值) .git / config fi le,并且gem只会在你的Git遥控器中找到一个在URL中具有heroku.com的遥控器,它将使用该遥控器。
  3. 如果这些工作都不起作用,错误指示您将 - app 传递给您的命令。


I have an existing Rails app on GitHub and deployed on Heroku. I'm trying to set up a new development machine and have cloned the project from my GitHub repository. However, I'm confused as to how to link this folder up to Heroku. Originally, I used the heroku create command, but obviously I don't want to do that this time since it will create another Heroku instance.

解决方案

Heroku links your projects based on the heroku git remote (and a few other options, see the update below). To add your Heroku remote as a remote in your current repository, use the following command:

git remote add heroku git@heroku.com:project.git

where project is the name of your Heroku project (the same as the project.heroku.com subdomain). Once you've done so, you can use the heroku xxxx commands (assuming you have the Heroku Toolbelt installed), and can push to Heroku as usual via git push heroku master. As a shortcut, if you're using the command line tool, you can type:

heroku git:remote -a project

where, again, project is the name of your Heroku project (thanks, Colonel Panic). You can name the Git remote anything you want by passing -r remote_name.

[Update]

As mentioned by Ben in the comments, the remote doesn't need to be named heroku for the gem commands to work. I checked the source, and it appears it works like this:

  1. If you specify an app name via the --app option (e.g. heroku info --app myapp), it will use that app.
  2. If you specify a Git remote name via the --remote option (e.g. heroku info --remote production), it will use the app associated with that Git remote.
  3. If you specify no option and you have heroku.remote set in your Git config file, it will use the app associated with that remote (for example, to set the default remote to "production" use git config heroku.remote production in your repository, and Heroku will run git config heroku.remote to read the value of this setting)
  4. If you specify no option, the gem finds no configuration in your .git/config file, and the gem only finds one remote in your Git remotes that has "heroku.com" in the URL, it will use that remote.
  5. If none of these works, it raises an error instructing you to pass --app to your command.

这篇关于如何链接一个文件夹与现有的Heroku应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆