Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)



Cloud Repositories

Cloud Repositories are fully-featured Git repositories hosted on the Google Cloud Platform. Each project you create in the Cloud Developers Console has one such repository. Cloud Repositories are free and are hosted on the same secure storage infrastructure used by Google's own services and applications. Once you have set up a Cloud Repository, you can configure local Git repositories to use it directly as a remote , or connect it to a repository on GitHub for collaborative development. Cloud Repositories support the standard set of Git commands, including push , pull , clone and log .

You can use a Cloud Repository to store the source code for any development project. By default, the master branch of the Cloud repository is used by Release Pipelines , which allow you to automate the process of building, testing and deploying an App Engine application. Pushing to the master branch either directly from a local Git repository or via GitHub triggers the Release Pipeline, if any, associated with a Cloud project and starts the deployment of the App Engine application.

Installing Git

If Git is not installed on your local system, download and install it.

Creating a Cloud project

If you don't already have a Cloud project, you must create one. When you create the project, note its project ID, as you will use it in subsequent steps.

To create a new Cloud project:

  1. Open the Cloud Developers Console .

  2. Click Create Project .

  3. Enter a project name and a project ID or accept the defaults.

  4. Click Create .

Setting up the repository as a Git remote

One way to use a Cloud Repository is to configure it as a remote to a Git repository on your local workstation. You can then push code to the repository, pull code from it, clone its contents and perform other standard Git operations.

Setting up the Cloud Repository

New Cloud projects have a Cloud Repository by default. If you have an older project or you have previously deleted the repository, you must create one manually in the Cloud Developers Console.

To set up the Cloud Repository:

  1. Open your project in the Cloud Developers Console .

  2. Select SOURCE CODE > Releases in the left-hand navigation panel.

  3. If prompted, click Create a New Repo .

Creating and configuring the local Git repository

To create and configure the local Git repository:

  1. If the Google Cloud SDK is not installed on your local system, download and install it.

  2. At a command prompt, navigate to the parent directory under which you want your project directory to be located.

  3. Run gcloud auth login at the prompt. This command acquires credentials for your Cloud Repository and configures the local instance of Git to use them.

    $ gcloud auth login
    

    The gcloud auth login command prints an authentication URL to the terminal. If you are running the command on a local system, this URL opens automatically in a browser on your desktop. If you are running the command on a remote system (for example, using ssh ), you must manually paste the URL into a browser window and then manually paste the acquired token back into the terminal.

  4. Read and consider the permissions request that appears in the browser window. Click Accept to accept the request.

  5. If prompted at the command line, enter your Cloud project ID.

  6. Run gcloud init . This command creates the local Git repository and adds the Cloud Repository as the Git origin remote.

    $ gcloud init <project>
    

    where <project> is the project ID of your Cloud project.

    gcloud init creates a directory named <project>/default in the current directory. This directory holds your local Git repository.

After you have created and configured the local Git repository, you can add the source code for your project and commit the changes using the Git add and commit commands. When you are ready to push the code to the Cloud repository, use the Git push command as follows:

$ git push origin <branch>

where <branch> is the branch where you want to push the code. If you are using Release Pipelines , the pipeline is triggered when you push code to the repository master branch.

Connecting a GitHub repository

Another way to use a Cloud Repository is to connect it to a repository on GitHub via a GitHub webhook . This configuration requires you to have an active account on GitHub.com and a GitHub repository where you intend to store your project source code. When you push code from a local repository to the GitHub repository, the webhook pushes the same code from GitHub to your Cloud Repository.

To create a new Cloud Repository and connect it to a repository on GitHub:

  1. Open your project in the Cloud Developers Console .

  2. Select SOURCE CODE > Releases in the left-hand navigation panel.

  3. Click Connect a GitHub Repo .

  4. Enter the GitHub repository URL in the dialog box that appears. The repository URL is in the format https://github.com/username/repository . This is the same URL that you open in your web browser when you are viewing the repository on the GitHub site.

  5. Read and consider the authentication request displayed in the dialog box. Select the Consent option if you consent to the request.

  6. Click Connect .

  7. Authorize access to your repository in the page on GitHub.com when prompted.

After you have connected the GitHub repository, you can create a Git repository on your local system, configure it to use the GitHub repository as a remote and then use standard Git operations as required by your workflow. When you are ready to push the code to the Cloud Repository via GitHub, use the Git push command as follows:

$ git push <remote> <branch>

where <remote> is the remote name you use to reference the GitHub repository and <branch> is the branch where you want to push the code. If you are using Release Pipelines , the pipeline is triggered when you push code to the repository master branch.

Viewing repository contents

To view the repository contents:

  1. Open your project in the Cloud Developers Console .

  2. Select SOURCE CODE > Browse in the left-hand navigation panel.

  3. Select a repository branch.

  4. Do one of the following:

    • Click Source to view the files in the branch at the current commit level and then click the name of a source file to view its contents.
    • Click History to view a history of commits to the branch and then click the commit ID or message to view a list of files committed. You can click on the name of a file to view changes between committed versions.

Using Source Code Tools

A preview release of Source Code tools is available in the Cloud Developers Console . These tools enable features such as:

  • Browsing source code
  • Deploying a quick fix instantly
  • Linking logs to source
  • Viewing a commit
  • Viewing commit history

To learn more, see Source Code Tools .

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.