Skip to content

Instantly share code, notes, and snippets.

@wotupset
Last active April 19, 2023 04:14
Show Gist options
  • Save wotupset/24b4c5dc0e0d4e26b53a5e468a88628f to your computer and use it in GitHub Desktop.
Save wotupset/24b4c5dc0e0d4e26b53a5e468a88628f to your computer and use it in GitHub Desktop.
Heroku Command Line Interface (CLI) 使用筆記
官網下載
https://devcenter.heroku.com/articles/heroku-cli
安裝heroku-windows-amd64.exe
安裝完Heroku 會安裝Git
預設資料夾是
C:\Program Files\Heroku
C:\Program Files\Git
執行
C:\Program Files\Git\git-bash.exe
輸入指令
heroku --version
有出現版本號
heroku-cli/5.6.12-1708b34 (windows-amd64) go1.7.4
就表示安裝成功
輸入指令
heroku login
會要求你輸入heroku的帳號密碼
輸入指令
heroku create
是建立新的app (直接在官網上新增app也可以)
成功會出現
Creating app... done, serene-bayou-53255
字串
serene-bayou-53255
是你app的名稱
你的網址會以
https://serene-bayou-53255.herokuapp.com/
的方式出現
app名稱可以改
官網>app>setting>names
就可以改名稱
git-bash.exe
輸入指令
cd 資料夾位置
切換資料夾
像是
cd C:\_heroku
切換成功後MINGW64後面會加上資料夾名稱
像是
MINGW64 /c/_heroku
輸入指令
git init
建立.git工作資料夾(這是隱藏的資料夾)
如果建立失敗 出現
Permission denied
表示需要確認權限
(可能是因為你指定的是系統資料夾底下的目錄 像是C:\Program Files)
你可以選擇其他目錄
或是用右鍵點git-bash.exe 點[以系統管理員身分執行]
把你要上傳的東西
放進
C:\_heroku
之後
git-bash.exe
輸入指令
heroku git:remote -a serene-bayou-53255
加入app位置到remote
其中
serene-bayou-53255
是目標app名稱
heroku會自動幫你把app的git連結加入到 .git資料夾底下的config
內容大概是
[remote "heroku"]
url = https://git.heroku.com/serene-bayou-53255.git
fetch = +refs/heads/*:refs/remotes/heroku/*
輸入指令
git add .
處理目錄底下的所有檔案
輸入指令
git commit -am "註解說明"
這次更新的註解說明
輸入指令
git push heroku master
推送檔案到heroku的master分支
出現
remote: Verifying deploy... done.
字串
就表示推送成功
推送成功後
可以在
https://你的app名稱.herokuapp.com/
看到你的成果
常見的首頁檔案名稱為
index.php index.htm
這樣進到首頁才能看到東西
@wotupset
Copy link
Author

wotupset commented Jan 17, 2017

暫存區
++
強制推送檔案
git push heroku master --force
拉取檔案
git pull heroku master

@wotupset
Copy link
Author

新增資料庫功能
heroku addons:create heroku-postgresql:hobby-dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment