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.
Why GitLab?
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:
- Unified DevSecOps platform
- Consolidate your entire development lifecycle into a single application, from planning to monitoring. Eliminate tool sprawl and dramatically boost productivity.
- Seamless Google Cloud integration
- Effortlessly connect with GKE, Cloud Build, and Cloud Storage, ensuring a smooth migration and efficient operations within the Google Cloud ecosystem.
- Advanced CI/CD capabilities
- Leverage Auto DevOps to automate everything from security scanning to deployment, accelerating your development cycles.
- Industry-recognized AI coding assistance
- Benefit from built-in AI-assisted development with GitLab Duo, fostering a secure and efficient coding environment.
Prerequisites
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.
Migration steps
- 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
andwrite_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.
- Inspect Git status: Run
git status
in the Cloud Shell to check the current branch and ensure everything is in order before pushing to GitLab.
- Set Up the Remote Repository: Add your GitLab project as a remote repository by running:
git remote add origin [GITLAB_PROJECT_URL]
- Replace
[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]
- Replace
[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.
Best practices
- 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.