如何在Heroku上针对特定Ruby on Rails应用进行代码推送?

更新于
2026-10-03 20:48:17
2阅读来源:SEO基础
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计379个文字,预计阅读时间需要2分钟。

使用heroku create test-app3创建了一个新的heroku应用。若想将一些代码推送至这个新的test-app3,可在终端执行以下步骤:

1. 切换到包含代码的目录。

2.初始化Git仓库(如果尚未初始化):`git init`

3.添加所有文件到Git仓库:`git add .`

4.提交更改:`git commit -m Initial commit`

5.连接到heroku:`heroku login`

6.将代码推送至heroku:`git push heroku master`

在终端输入heroku列表命令,会得到类似以下结果:

我的应用 test-app1 test-app2 t

我使用heroku create test-app3创建了一个新的heroku应用程序.现在,如果我想将一些代码推送到这个新的test-app3,我该怎么做?

当我在终端输入heroku列表时,我得到:
我的应用

> test-app1
> test-app2
> test-app3

我如何推送test-app3?如何在要推送的应用程序之间切换?

您需要为Heroku中的每个应用程序设置不同的git远程端点,以便您可以从一个本地存储库推送到任一应用程序.

通过仪表板在Heroku上获取应用程序的GIT URL(它看起来与此类似:git@heroku.com:your_app_name.git)并执行:

git remote add test-app1 git@heroku.com:test-app1.git git remote add test-app2 git@heroku.com:test-app2.git git remote add test-app3 git@heroku.com:test-app3.git

然后你就可以推送到这样的任何特定应用:

git push test-app1 master git push test-app2 master git push test-app3 master

本文共计379个文字,预计阅读时间需要2分钟。

使用heroku create test-app3创建了一个新的heroku应用。若想将一些代码推送至这个新的test-app3,可在终端执行以下步骤:

1. 切换到包含代码的目录。

2.初始化Git仓库(如果尚未初始化):`git init`

3.添加所有文件到Git仓库:`git add .`

4.提交更改:`git commit -m Initial commit`

5.连接到heroku:`heroku login`

6.将代码推送至heroku:`git push heroku master`

在终端输入heroku列表命令,会得到类似以下结果:

我的应用 test-app1 test-app2 t

我使用heroku create test-app3创建了一个新的heroku应用程序.现在,如果我想将一些代码推送到这个新的test-app3,我该怎么做?

当我在终端输入heroku列表时,我得到:
我的应用

> test-app1
> test-app2
> test-app3

我如何推送test-app3?如何在要推送的应用程序之间切换?

您需要为Heroku中的每个应用程序设置不同的git远程端点,以便您可以从一个本地存储库推送到任一应用程序.

通过仪表板在Heroku上获取应用程序的GIT URL(它看起来与此类似:git@heroku.com:your_app_name.git)并执行:

git remote add test-app1 git@heroku.com:test-app1.git git remote add test-app2 git@heroku.com:test-app2.git git remote add test-app3 git@heroku.com:test-app3.git

然后你就可以推送到这样的任何特定应用:

git push test-app1 master git push test-app2 master git push test-app3 master