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 Manage resources page

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

Create a new repository

From the command line run

gcloud init
gcloud source repos create REPO_NAME

Clone a repository

Clone the contents of an existing Cloud Source Repository:

gcloud source repos clone REPO_NAME

The gcloud source repos clone command adds the Cloud Source Repository as a remote named origin and clones it into a local Git repository.

Note for MacOS users: When using a tool for your git operations that does not include gcloud in the path, you will need to qualify your clone command with the full gcloud path for the credential helper to work. See Cloning a Repository for more detail.

Note for Windows users: Some of the standard git installations set a system-wide credential helper. If this credential manager creates a dialog box asking for a username and password, click cancel to allow the gcloud CLI to supply credentials.

Push to the Cloud Source Repository

Create a file in your repository:

echo "Hello World!" > myfile.txt

Commit the file using git:

git add myfile.txt
git commit -m "First Cloud Source Repository file" myfile.txt

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

git push origin master

Git pushes the sample application files from the master branch to the origin 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 myfile.txt 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