2016年3月30日 星期三

OpenShift 利用 Git 同步步驟

安裝 Ruby


http://rubyinstaller.org/downloads/archives 選取 Ruby 1.9.3-p551

或者由此連結下載 Ruby 1.9.3-p551 (有可能會失效)

進入安裝畫面


安裝 Git


進入 Git 下載頁面 Download Page 自行選擇32位元,還是64位元的軟體。

進入安裝畫面









驗證 Git 是否正常工作


開啟「開始工具列點」選 Git bash 來輸入指令

輸入下列指令:
~$ ruby -v
~$ gem -v
~$ git --version



安裝 OpenShift 客戶端工具 rhc


開啟 CMD 或者  Git bash 來輸入指令:
~$ gem install rhc
安裝需要一點時間,等待安裝完成


設定登入 openshift 上傳 SSH 公鑰


開啟 CMD 或者  Git bash 來輸入指令:
~$ rhc setup
設定相關問答
Enter the server hostname: |openshift.redhat.com| (預設選項,直接按Enter繼續)

Login to openshift.redhat.com: (輸入OpenShift的帳號)

Password: (輸入OpenShift的密碼)

OpenShift can create and store a token on disk which allows to you to access the server without
using your password. The key is stored in your home directory and should be kept secret.  You can
delete the key at any time by running 'rhc logout'.
(OpenShift 產生一組憑證到你的家目錄中,如果你要刪除它可以執行 'rhc logout')

Generate a token now? (yes|no) (產生憑證?輸入 y 繼續)

Your public SSH key must be uploaded to the OpenShift server to access code.  Upload now? (yes|no) (上傳公鑰到OpenShift伺服器中?輸入 y 繼續)

Provide a name for this key: |預設公鑰名稱|(如果不設定按Enter維持預設名稱即可)

回到 openshift 的 Settings 頁面,你可以看見你剛剛建立的公鑰



回到 openshift 的 Application 頁面,複製 SSH 鍊結



同步 Git 資料夾


在本機你要鏡射的路徑下,開啟 CMD 或者 Git bash 來輸入指令:
~$ git clone ssh://56fbad440c1e66983600002d@hello2-7685.rhcloud.com/~/git/hello2.git/
(上面路徑每個人都不相同,請勿直接複製這個鍊結)

同步完成的檔案


以後若要同步 Git,一樣開啟 CMD 或者 Git bash 來輸入下面指令,來完成同步動作
~$ git add .
~$ git commit -m "ok"
~$ git push

參考資料:
1. https://www.openshift.com/developers/rhc-client-tools-install