如何将文件夹与现有 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
Heroku 基于
heroku
git 远程链接您的项目(以及其他一些选项,请参阅更新如下)。要将 Heroku 远程添加为当前存储库中的远程,请使用以下命令:其中
project
是 Heroku 项目的名称(与project.heroku.com
相同) > 子域)。完成此操作后,您可以使用heroku xxxx
命令(假设您有 Heroku Toolbelt 安装),并且可以像往常一样通过 git push heroku master 推送到 Heroku。作为快捷方式,如果您使用命令行工具,您可以输入:其中,
project
是您的 Heroku 项目的名称(谢谢,恐慌上校)。您可以通过传递-r remote_name
为 Git 远程命名任何您想要的名称。[更新]
正如 Ben 在评论中提到的,遥控器不需要命名为
heroku
即可让 gem 命令正常工作。我检查了源,看起来它工作原理如下:--app
选项指定应用程序名称(例如heroku info --app myapp
),它将使用该应用程序。--remote
选项指定 Git remote 名称(例如heroku info --remote production
),它将使用关联的应用程序使用 Git 遥控器。heroku.remote
,它将使用与该远程关联的应用程序(例如,要将默认远程设置为“生产”,请使用git config heroku.remote production
在你的存储库中,Heroku 将运行git config heroku.remote
来读取此设置的值).git/config
文件中,并且 gem 仅在您的 Git 遥控器中找到一个 URL 中包含“heroku.com”的遥控器,它将使用该遥控器。--app
传递给您的命令。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:where
project
is the name of your Heroku project (the same as theproject.heroku.com
subdomain). Once you've done so, you can use theheroku xxxx
commands (assuming you have the Heroku Toolbelt installed), and can push to Heroku as usual viagit push heroku master
. As a shortcut, if you're using the command line tool, you can type: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:--app
option (e.g.heroku info --app myapp
), it will use that app.--remote
option (e.g.heroku info --remote production
), it will use the app associated with that Git remote.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" usegit config heroku.remote production
in your repository, and Heroku will rungit config heroku.remote
to read the value of this setting).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.--app
to your command.Heroku CLI 为此提供了一个简单的快捷方式。对于名为“falling-wind-1624”的应用程序:
请参阅 https:// devcenter.heroku.com/articles/git#creating-a-heroku-remote
The Heroku CLI has an easy shortcut for this. For an app named 'falling-wind-1624':
See https://devcenter.heroku.com/articles/git#creating-a-heroku-remote
不要忘记,如果您也在一台之前没有设置过 heroku 的机器上
,或者您将无法推送或拉取存储库。
Don't forget, if you are also on a machine where you haven't set up heroku before
Or you won't be able to push or pull to the repo.
然后检查远程仓库:
then check the remote repo :
为旧应用程序设置新的部署系统时需要注意两件事
。 1. 要检查您的应用程序对 Heroku 的访问权限(尤其是应用程序),
它将列出您有权访问的应用程序
如果您是第一次设置,您可能需要
2. 然后设置 git 远程
对于已创建的 Heroku 应用程序,您可以使用
heroku git:remote命令。您所需要的只是 Heroku 应用程序的名称:
您还可以使用 git remote rename 命令重命名您的遥控器:
然后您可以使用 git remote 命令来确认已为您的应用程序设置了遥控器
Two things to take care while setting up a new deployment System for old App
1. To check your app access to Heroku (especially the app)
it will list the apps you have access to
if you set up for the first time, you probably need to
2. Then set up your git remote
For already created Heroku app, you can easily add a remote to your local repository with the
heroku git: remote
command. All you need is your Heroku app’s name:you can also rename your remotes with the git remote rename command:
then You can use the git remote command to confirm that a remote been set for your app
使用heroku的fork
使用新的“heroku fork”命令!它将复制所有环境,之后你必须更新 github 存储库!
克隆到本地
在 github 上创建一个新的存储库并添加它
在github上推送
Use heroku's fork
Use the new "heroku fork" command! It will copy all the environment and you have to update the github repo after!
Clone it local
Make a new repo on github and add it
Push on github
您应该启动 ssh-agent 并添加您的密钥。检查一下,
http://wordgraphs.com/post/5000/Heroku--Permission-denied--publickey---fatal--Could-not-read-from-remote-repository-
它帮助了我。
You should probable start ssh-agent and add your keys. Check this,
http://wordgraphs.com/post/5000/Heroku--Permission-denied--publickey---fatal--Could-not-read-from-remote-repository-
It helped me.
我的项目位于github和heroku中,用于上传heroku使用:
文档是:
https:/ /devcenter.heroku.com/articles/git
I've my project in github and heroku, for upload an heroku use :
The doc it is:
https://devcenter.heroku.com/articles/git
对于终端中的现有存储库
类型
$ heroku git:remote -a example
for existing repository
type in terminal
$ heroku git:remote -a example