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
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:
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
Add the repository as a remote named
git remote add google https://source.developers.google.com/p/[PROJECT_ID]/r/[REPO_NAME]
[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
git push command:
git push google master
Git pushes the sample application files from the
master branch to the
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:
The console shows the files in the master branch at the most recent commit.
View a file in the Cloud Source Repository
main.py to view its contents in the source code browser.
To delete the repository you created:
Open the source view in the Cloud Platform Console:
Click the More button next to the repository you want to delete.
Enter the name of the repository where prompted and then confirm deletion.