的documentation爲谷歌雲平臺描述了許多文件傳送到谷歌Compute Engine執行個體的方式。但它沒有提到如何使用Git來做到這一點。此外,雖然我在Web控制檯的「開發」下提供了Google Cloud代碼庫,但他不清楚如何將這些代碼與Compute實例相關聯。如何從本地計算機「混帳」到Google雲端平臺實例?
怎樣一個Git倉庫與谷歌Compute Engine的實例,並git push
從我的本地機器的情況下回購相關聯?
的documentation爲谷歌雲平臺描述了許多文件傳送到谷歌Compute Engine執行個體的方式。但它沒有提到如何使用Git來做到這一點。此外,雖然我在Web控制檯的「開發」下提供了Google Cloud代碼庫,但他不清楚如何將這些代碼與Compute實例相關聯。如何從本地計算機「混帳」到Google雲端平臺實例?
怎樣一個Git倉庫與谷歌Compute Engine的實例,並git push
從我的本地機器的情況下回購相關聯?
你必須遠程定義這個動作。 (用git遠程添加/設置URL)
# Add new remote
git remote add godaddy1 [email protected]:~/root.git
# replace the current remote if want to replace instead of adding a new one
git remote set-url godaddy [email protected]:~/root.git
# List all remotes
git remote -v
但是,如何指定我的Google Compute Instance,或將我的repo與實例關聯? – orome
你需要找出你的谷歌Git倉庫的網址並進行設置。它可以在您的谷歌帳戶 – CodeWizard
找到這裏是一個鏈接:https://cloud.google.com/source-repositories/docs/adding-repositories-as-remotes – CodeWizard
由於一個SSH服務默認情況下,在GCE Linux的虛擬機上運行,只要按照下列步驟操作:
gcloud auth login
授權gcloud訪問Google雲端平臺。gcloud compute config-ssh
填充SSH配置文件與每個實例主機條目。測試ssh方式連接到你的虛擬機實例運行ssh NAME.ZONE.PROJECT
例子:ssh example-instance.us-central1-a.MY-PROJECT
建立一個空庫在VM:
$ mkdir project.git
$ cd project.git
$ git init --bare
在本地計算機上添加遠程倉庫:
git remote add origin NAME.ZONE.PROJECT:/<PATH>/project.git
現在,你應該能夠到您的項目推到你的虛擬機的Git倉庫。
這是一個有趣的想法,但我從來沒有見過它在實踐中完成。人們通常使用諸如Ansible,Chef和Puppet等CM工具。對於簡單的案例,我喜歡易於學習的Fabric,它允許您使用Python編寫代碼推送和主持管理任務,並通過SSH工作。 – jarmod