Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Labs

Migrating Source Code to a Google Cloud Source Repository

Working with code is an everyday reality for cloud application developers, and Google Cloud provides a service that makes it easy to access your code for Google Cloud projects: Source Repositories. This hands-on lab is divided into two parts. In the first part of the lab, you’ll create a new Source Repository and populate it with example code using the `git` command. Once you have pushed the code to the repo, you’ll use the Source Repository interface to inspect the files. In the second part of the lab, you’ll set up another Source Repository to mirror your own existing GitHub repository. Please note it is a prerequisite for this part of the lab to have your own GitHub account and at least one repository.

Labs

Path Info

Level
Clock icon Beginner
Duration
Clock icon 30m
Published
Clock icon Feb 21, 2019

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Enable the Source Repository API.

    Use the API Library to find and enable the Google Cloud Source Repository API.

  2. Challenge

    Create a Source Repository.

    Use the command:

    gcloud source repos create gcpro_repo
    
  3. Challenge

    Clone the Source Repository.

    Use the command:

    gcloud source repos clone gcpro_repo
    
  4. Challenge

    Confirm the cloned repo.

    Use the ls command to view the new cloned repo and then cd into that folder.

  5. Challenge

    Create an example file.

    Use the echo command to create a new file.

  6. Challenge

    Push the new content to the Source Repository repo.

    1. Configure two variables user.email and user.name.
    2. Add the file: git add greetings.txt
    3. Commit the file: git commit -m "Committed initial file" greetings.txt
  7. Challenge

    Push the file from the master branch to origin.

    Use the command:

    git push origin master
    
  8. Challenge

    Confirm the operation.

    1. From the Source Repositories dashboard, click the gcpro_repo repo.
    2. Click the greetings.txt file to review the contents.
  9. Challenge

    Return to the main repository page.

    Click Cloud Source Repositories in the upper-left. Return to the main repository page where you have at least one repository.

  10. Challenge

    Create new repository.

    1. From the Source Repository dashboard, click Add repository.
    2. In the "Add a Repository" dialog, choose Connect external repository.
    3. On the Connect External Repository page, select the current project and then, from the Git Provider list, choose GitHub.
    4. When the Consent checkbox appears, select it.
    5. Choose Connect to GitHub.
    6. From the list of your repos, select one.
    7. Click Connect selected repository.
  11. Challenge

    Confirm the operation.

    When the files of the repo are displayed, select one to open and confirm its contents.

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.

Start learning by doing today

View Plans