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

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

问题描述

我在 GitHub 上有一个现有的 Rails 应用程序并部署在 Heroku 上.我正在尝试设置一台新的开发机器并从我的 GitHub 存储库中克隆了该项目.但是,我对如何将此文件夹链接到 Heroku 感到困惑.最初,我使用了 heroku create 命令,但显然这次我不想这样做,因为它会创建另一个 Heroku 实例.

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 根据

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

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

其中 project 是您的 Heroku 项目的名称(与 project.heroku.com 子域相同).完成后,您可以使用 heroku xxxx 命令(假设您有 Heroku Toolbelt 安装),并且可以像往常一样通过 git push heroku master 推送到 Heroku.作为一种快捷方式,如果您使用的是命令行工具,则可以键入:

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

同样,project 是您的 Heroku 项目的名称(感谢,Colonel Panic).你可以通过传递 -r remote_name 来命名 Git 远程任何你想要的名字.

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.

[更新]

正如 Ben 在评论中提到的,远程不需要被命名为 heroku 才能让 gem 命令工作.我检查了,它出现了像这样工作:

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. 如果您通过 --app 选项指定应用名称(例如 heroku info --app myapp),它将使用该应用.
  2. 如果您通过 --remote 选项指定 Git remote 名称(例如 heroku info --remote production),它将使用与该 Git 远程关联的应用.
  3. 如果您没有指定任何选项并且您在 Git 配置文件中设置了 heroku.remote,它将使用与该遥控器关联的应用程序(例如,将默认遥控器设置为生产"在你的仓库中使用 git config heroku.remote production,Heroku 将运行 git config heroku.remote 来读取这个设置的值)
  4. 如果您不指定任何选项,gem 将在您的 .git/config 文件中找不到任何配置,并且 gem 只会在您的 Git 遥控器中找到一个在 URL 中包含heroku.com"的遥控器,它将使用那个遥控器.
  5. 如果这些都不起作用,则会引发错误,指示您将 --app 传递给您的命令.
  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 work, it raises an error instructing you to pass --app to your command.

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

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