Published on: August 28, 2024
3 min read
Google Cloud is deprecating Cloud Source Repositories. Learn how to migrate a CSR source code repository to GitLab, along with best practices.
Google Cloud’s deprecation of Cloud Source Repositories (CSR) has prompted development teams to seek a full-featured alternative for their source code repositories. GitLab, a Google Cloud Technology Partner, is a strong choice due to its comprehensive DevSecOps capabilities.
In this tutorial, you'll learn the steps to ensure a smooth transition from CSR to GitLab, whether you're using GitLab.com or a self-managed instance on Google Cloud.
Transitioning from Google Cloud Source Repositories to GitLab is a recommended step. As a strategic partner of Google Cloud, GitLab seamlessly integrates with existing infrastructure with ease and brings value to customers in the following ways:
Before you start the migration, ensure you have:
GitLab account: Set up your account on GitLab.com or on a self-hosted instance.
GitLab project: Create a blank project in GitLab where the CSR repository will be migrated.
Create a blank GitLab project: This will serve as the destination for your migrated CSR repository. Keep this project empty for now.
Generate a personal access token (PAT): Navigate to GitLab settings and
generate a
PAT
with read_repository
and write_repository
scopes enabled. This token
will be used to authenticate your Git operations during the migration
process.
Edit code in Cloud Shell Editor: From your CSR repository, open the Cloud Shell Editor by clicking the “Edit code” button. You’ll need to authorize the Cloud Shell and select “Trust repo” to proceed.
git status
in the Cloud Shell to check the
current branch and ensure everything is in order before pushing to GitLab.
git remote add origin [GITLAB_PROJECT_URL]
[GITLAB_PROJECT_URL]
with the actual URL of your GitLab
project.Push to GitLab: Finally, push your local repository to GitLab by running:
git push -u origin [BRANCH_NAME]
[BRANCH_NAME]
with the current branch name you noted earlier.When prompted, use your GitLab username and the PAT as the password to authenticate and complete the push.
Back up before you begin: Always back up your CSR repository before starting the migration process.
Test after migration: Ensure all aspects of the repository, including branches and CI/CD pipelines, are functioning as expected in GitLab.
Leverage GitLab features: Take advantage of GitLab’s advanced DevSecOps features such as AI, CI/CD, and Enterprise Agile planning to enhance your development workflow.
Moving from Google Cloud Source Repositories to GitLab is easy and offers more benefits than just managing source code. GitLab, with its integration with Google Cloud, makes it an ideal choice for developers seeking to enhance their workflow post-migration.
Read more about GitLab's integration with Google Cloud.