You can add a Cloud Source Repository as a remote to a local Git repository and use it in the same way you use other Git remotes.
Before you begin
Select or create a Cloud Platform project.
- Install Git.
- Install and initialize the Cloud SDK.
- Create a Cloud Source Repository
Adding the repository as a remote
Change your current working directory to the directory that contains your local Git repository:
Run the credential helper script (on Linux or Mac OS X):
git config credential.helper gcloud.sh
Or on Windows:
git config credential.helper gcloud.cmd
The credential helper scripts provide the information needed by Git to connect securely to the Cloud Source Repository using your Google account credentials. You don't need to perform any additional configuration steps (for example, uploading
sshkeys) to establish this secure connection.
Note that the
gcloudcommand-line tool must be in your
$PATHfor the credential helper scripts to work.
If you cannot use the
gcloudtool (e.g. you are on a build server)
You may use static credentials by manually generating them in the cloud-console.
- Go to the repository page
and click the clone button, then change the preferred authentication method
manually generated credentialsand follow the instructions to use the generated credentials.
- Go to the repository page and click the clone button, then change the preferred authentication method to
Add the Cloud Source Repository as a remote:
gcloud source repos create [YOUR_REPO] git remote add google\ https://source.developers.google.com/p/[PROJECT_ID]/r/[YOUR_REPO]
[PROJECT_ID]is the ID of your Cloud Platform project and
[YOUR_REPO]is the name of your Cloud Source Repository.
Using the repository as a remote
A Cloud Source Repository is a fully-featured Git repository. You can use the
standard set of Git commands to interact with the repository, including
Pushing to a Cloud Source Repository
To push from your local Git repository to the Cloud Source Repository:
git push google master
Pulling from a Cloud Source Repository
To pull from the Cloud Source Repository to your local Git repository:
git pull google master
Viewing the commit history from a Cloud Source Repository
To view the commit history:
git log google/master
After you have pushed source files to the Cloud Source Repository, you can view repository files from within the Google Cloud Platform Console.