You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Google Cloud Source Repositories (CSR) is a fully managed, private Git hosting service on Google Cloud. It provides Git repositories hosted on Google's infrastructure with integration into Cloud Build, IAM-based access control, and the ability to mirror repositories from GitHub and Bitbucket.
Cloud Source Repositories is Google Cloud's native Git hosting service. It provides private Git repositories with the same reliability and security as other Google Cloud services.
| Characteristic | Description |
|---|---|
| Fully managed | No servers to maintain — Google handles availability and scaling |
| Private | All repositories are private by default |
| Integrated | Native integration with Cloud Build, Debugger, and Logging |
| Mirroring | Mirror repositories from GitHub and Bitbucket |
| IAM | Access control through Google Cloud IAM |
| Unlimited repos | No limit on the number of repositories per project |
| Free tier | Up to 5 users and 50 GB of storage free |
# Create a new repository
gcloud source repos create my-repo
# List all repositories in the project
gcloud source repos list
# Describe a repository
gcloud source repos describe my-repo
# Clone using gcloud (sets up authentication automatically)
gcloud source repos clone my-repo
# Clone using the manual URL
git clone https://source.developers.google.com/p/my-project/r/my-repo
Cloud Source Repositories supports multiple authentication methods:
| Method | Use Case |
|---|---|
| gcloud credential helper | Local development (recommended) |
| SSH keys | Developers who prefer SSH |
| Service account keys | CI/CD pipelines |
| Cookie-based | Google Cloud Console |
# Set up the gcloud credential helper
git config --global credential.https://source.developers.google.com.helper gcloud.sh
Cloud Source Repositories can mirror external repositories from GitHub or Bitbucket. Changes pushed to the external repository are automatically synced to CSR.
Mirrored repositories are read-only in CSR — all changes must be pushed to the external repository.
| Role | Description |
|---|---|
roles/source.reader | Clone and fetch from repositories |
roles/source.writer | Push to repositories |
roles/source.admin | Create, delete, and manage repositories |
# Grant read access to a developer
gcloud projects add-iam-policy-binding my-project \
--member="user:developer@example.com" \
--role="roles/source.writer"
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.