1. 在heroku网站上注册账号
要使用gmail邮箱进行注册
2. 安装heroku CLI
https://devcenter.heroku.com/articles/getting-started-with-python#set-up
3. 用终端登陆heroku
$ heroku login
输入邮箱和密码
4. 在heroku上创建一个app的仓库
下面的命令都是在git bash中执行
这里会随机生成一个app的名称(floating-sands-17593),后面可以更改app的名称
$ heroku create
Creating app... done, floating-sands-17593
https://floating-sands-17593.herokuapp.com/ | https://git.heroku.com/floating-sands-17593.git
如果之前有自己在GitHub上有自己的server的仓库,并且想把自己的仓库放到heroku上面运行,那么可以执行下面命令在自己的仓库下,与heroku仓库进行关联,之后git remote -v命令可以看出时关联上两个仓库,heroku和origin仓库:
$ heroku git:remote --app floating-sands-17593
set git remote heroku to https://git.heroku.com/floating-sands-17593.git
$ git remote -v
heroku https://git.heroku.com/floating-sands-17593.git (fetch)
heroku https://git.heroku.com/floating-sands-17593.git (push)
origin git@github.com:xxxxxxx/myserver.git (fetch)
origin git@github.com:xxxxxxx/myserver.git (push)
之后,当我们提交代码到自己的origin仓库时,可以执行下面的命令,将修改也提交的本地的heroku仓库的master分支:
$ git push origin HEAD:heroku/master
Total 0 (delta 0), reused 0 (delta 0)
To https://github.com/xxxxxxx/myserver
30b7661..3f8b4e2 HEAD -> heroku/master
再执行下面的命令,将本地heroku仓库mater分支的代码提交到自己远程的heroku仓库master分支
$ git push heroku master
Counting objects: 6, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing obje