通过 Cloud Code,您可以将新项目添加到 Cloud Source Repositories,还可以签出 现有项目。
准备工作
- 登录您的 Google Cloud 账号。如果您是 Google Cloud的新用户, 请创建一个账号,以便在 真实场景中评估我们产品的性能。新客户还可获享 $300 赠金,用于 运行、测试和部署工作负载。
-
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 role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. 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 role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
上传源代码
将代码从 Cloud Code 上传到 Cloud Source Repositories:
打开要添加到 Cloud Source Repositories 的项目。
依次点击 VCS > 上传到 Cloud Source Repositories 。或者,在 菜单中,依次前往工具 > Google Cloud Code > 上传到 Cloud Source Repositories。
在对话框中,使用相应下拉菜单选择与您的项目关联的 Cloud 项目 。
使用下拉菜单选择您的云端代码库。
如果您没有代码库,或者要创建新的代码库,请点击 Create a new cloud repository 。
Cloud Code 会打开一个跳转到 Google Cloud 控制台的新浏览器窗口,以便您可以创建新的代码库。
默认情况下,Cloud Code 会设置远程名称 。您可以在 New Remote Name 字段中输入其他名称。
点击上传 。
开发
如需执行提交和推送新更改等其他操作,请依次前往 VCS > VCS Operations Popup。
浏览源文件
上传源代码后,要在 Google Cloud 控制台中浏览它们,请执行以下步骤:
在 Google Cloud 控制台中,选择包含您的源代码的项目。
在搜索栏中,搜索
Cloud Source Repositories。
签出源代码
如需从 Cloud Source Repositories 中签出源代码,请执行以下操作:
- 选择 VCS > Get from Version Control 。或者,前往欢迎对话框,然后点击 Get from VSC 。
- 从 Version Control 下拉列表中选择 Google Cloud ,然后点击 Clone 。
- 在 Clone from Google Cloud 对话框中,选择与您的项目关联的 Cloud 项目 。
- 选择您的云端代码库。
- 选择父级目录。
- 输入目录名称。
- 点击克隆 。
您也可以从欢迎 屏幕中签出,方法是选择 Get from Version Control ,然后从“Version Control”下拉列表中选择 Google Cloud 。此时将显示 Clone from Google Cloud 对话框。