您可以透過 Cloud Code 將新專案加到 Cloud Source Repositories,以及取出現有的專案。
事前準備
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator
(
roles/resourcemanager.projectCreator
), which contains theresourcemanager.projects.create
permission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator
(
roles/resourcemanager.projectCreator
), which contains theresourcemanager.projects.create
permission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
開啟要新增至 Cloud Source Repositories 的專案。
依序點選「VCS」 >「Upload to Cloud Source Repositories」。或者,在選單中依序前往「Tools」>「Google Cloud Code」>「Upload to Cloud Source Repositories」。
在對話方塊中,在下拉式選單中選取與您專案相關聯的 Cloud 專案。
使用下拉式選單選取您的 Cloud Repository。
如果您沒有存放區,或要建立新的存放區,請按一下 [Create a new cloud repository]。
Cloud Code 會開啟新的瀏覽器視窗,連往Google Cloud 主控台,方便您建立新的存放區。
根據預設,Cloud Code 會設定遠端名稱。您可以在「New Remote Name」欄位中輸入不同名稱。
按一下「上傳」。
在 Google Cloud 控制台中,選取含有您原始碼的專案。
在搜尋列中搜尋
Cloud Source Repositories
。- 依序選擇「VCS」>「Get from Version Control」。或者,前往歡迎對話方塊,然後點選「Get from VSC」。
- 從「Version Control」(版本控制) 下拉式選單中選取「Google Cloud」,然後按一下「Clone」(複製)。
- 在「Clone from Google Cloud」(從 Google Cloud 複製) 對話方塊中,選取與您的專案相關聯的 Cloud 專案。
- 選取您的 Cloud Repository。
- 選取父項目錄。
- 輸入目錄名稱。
- 按一下 [Clone] (複製)。
上傳原始碼
從 Cloud Code 將原始碼上傳至 Cloud Source Repositories:
開發
如要執行其他作業 (例如提交及推送新變更),請依序前往「VCS」>「VCS Operations Popup」。
瀏覽來源檔案
上傳來源檔案之後,請瀏覽 Google Cloud 控制台中的程式碼:
查看原始碼
從 Cloud Source Repositories 取出原始碼:
或者,您也可以從「Welcome」畫面取出,方法是選取「Get from Version Control」,然後從「Version Control」下拉式選單選擇「Google Cloud」。「Clone from Google Cloud」(從 Google Cloud 複製) 對話方塊隨即顯示。