Quickstart

This page shows you how to set up a Cloud Source Repository and use it as a remote for a local Git repository. The sections below walk you through the steps of creating a local Git repository that contains files for a sample App Engine application, adding the Cloud Source Repository as a remote, and pushing the contents of the local repository.

Before you begin

  1. Select or create a Cloud Platform project.

    Go to the Projects page

  2. Install Git.
  3. Install and initialize the Cloud SDK.

Create a new repository

From the command line run

gcloud init
gcloud alpha source repos create REPO_NAME

Create a local Git repository

Create a Git repository on your local system and pull the source files for a sample application into it:

cd $HOME
git init local-repo
cd local-repo
git pull https://github.com/GoogleCloudPlatform/appengine-helloworld-python

Git pulls the sample application files into your new local repository:

remote: Counting objects: 21, done.
remote: Total 21 (delta 0), reused 0 (delta 0), pack-reused 21
Unpacking objects: 100% (21/21), done.
From https://github.com/GoogleCloudPlatform/appengine-helloworld-python
 * branch            HEAD       -> FETCH_HEAD

Add the Cloud Source Repository as a remote

You can use your recently created Cloud Source Repository as a remote to your local repository in the same way that you use other Git remotes. (A remote in Git is a remote version of your repository located on the Internet or elsewhere on another network.)

To add the repository as a remote:

  1. Authorize Git to access Google Cloud Platform:

    git config credential.helper gcloud.sh
    

    Note for Windows users: If your git configuration has set a system credential helper, you will first need to unset it.

    git config --system --unset credential.helper
    

    You can check whether a system credential helper has been set by looking for credential helper in the list for the following command.

    git config --system --list
    
  2. Add the repository as a remote named google to your local Git repository:

    git remote add google https://source.developers.google.com/p/[PROJECT_ID]/r/[REPO_NAME]
    

    where [PROJECT_ID] is the ID of your Cloud Platform project.

Push to the Cloud Source Repository

Add the contents of the local repository to the Cloud Source Repository using the git push command:

git push google master

Git pushes the sample application files from the master branch to the google remote:

Counting objects: 21, done.
Delta compression using up to 6 threads.
Compressing objects: 100% (20/20), done.
Writing objects: 100% (21/21), 9.76 KiB | 0 bytes/s, done.
Total 21 (delta 5), reused 0 (delta 0)
remote: Storing objects: 100% (21/21), done.
remote: Processing commits: 100% (6/6), done.
To https://source.developers.google.com/p/example-project-1244/r/repo-name
 * [new branch]      master -> master

Browse files in the Cloud Source Repository

Browse the sample files you pushed to the Cloud Source Repository:

Open the Source View in the Console

The console shows the files in the master branch at the most recent commit.

View repository files

View a file in the Cloud Source Repository

Click main.py to view its contents in the source code browser.

View repository file

Clean up

To delete the repository you created:

  1. Open the source view in the Cloud Platform Console:

    Open the Source View in the Console

  2. Click the More button More button next to the repository you want to delete.

    Create Repository button

  3. Select Delete.

  4. Enter the name of the repository where prompted and then confirm deletion.

What's next

Send feedback about...

Cloud Source Repositories