Blog Product Tutorial: Migrate from Google Cloud Source Repositories to GitLab
Published on: August 28, 2024
3 min read

Tutorial: Migrate from Google Cloud Source Repositories to GitLab

Google Cloud is deprecating Cloud Source Repositories. Learn how to migrate a CSR source code repository to GitLab, along with best practices.

migration - transfer - cover

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

  1. Create a blank GitLab project: This will serve as the destination for your migrated CSR repository. Keep this project empty for now.
  2. 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.
  3. 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.

Google Cloud Shell Editor

  1. 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.

Inspect Git status

  1. Set Up the Remote Repository: Add your GitLab project as a remote repository by running:
git remote add origin [GITLAB_PROJECT_URL]

  1. 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]

  1. 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.

We want to hear from you

Enjoyed reading this blog post or have questions or feedback? Share your thoughts by creating a new topic in the GitLab community forum. Share your feedback

Ready to get started?

See what your team could do with a unified DevSecOps Platform.

Get free trial

Find out which plan works best for your team

Learn about pricing

Learn about what GitLab can do for your team

Talk to an expert