在 Heroku 上部署代码

Deploy Code on Heroku

当我尝试 运行

git push heroku master

它给出错误说

fatal: 'heroku' does not appear to be a git repository
fatal: Could not read from remote repository.

就在 运行 执行此命令之前,我已将我的代码推送到 bitbucket,因此

git remote -v

正在显示

origin  https://prashant@bitbucket.org/prashant/code.git (fetch)
origin  https://prashant@bitbucket.org/prashant/code.git (push)

如何在 Bitbucket 上继续我的源代码版本控制的同时将我的代码部署到 heroku?

每次

时是否需要更改远程原点

我知道这听起来很荒谬,但作为初学者,这是我唯一想到的事情

编辑 步骤顺序:

heroku login 

Git init

heroku create

git add . 

git commit -am "give some comment"

git remote add origin https://prashant@bitbucket.org/prashant/code.git

git push heroku master

fatal: 'heroku' does not appear to be a git repository
fatal: Could not read from remote repository.

Heroku 和 Bitbucket 是两个不同的东西,虽然有些命令很相似。尝试将您的应用程序部署到 heroku。

我假设您已经在 heroku 上创建了帐户。如果没有 click here 就做一个。

转到您的终端,将目录更改为您的应用所在的目录,然后 运行 在命令

下方
heroku login 

Git init

heroku create

git add . 

git commit -am "give some comment"

git push heroku master

这会起作用,阅读这篇文章了解更多关于什么是 git 、 heroku 和 GitHub 的信息(GitHub 类似于 Bitbucket)

为了将分支推送到 Heroku,从而部署代码,必须将 Heroku 存储库配置为您的 git 项目的远程存储库。

这意味着,当您 运行 git remote 您应该在那里看到 Heroku 存储库。

要向现有 Heroku 应用程序添加 link 存储库,只需使用

$ git remote add heroku "PATH_TO_THE_HEROKU_APP"

另见 https://devcenter.heroku.com/articles/git#creating-a-heroku-remote

之后,您将能够通过 运行ning

进行部署
$ git push heroku master