- Lab
- A Cloud Guru
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.
Path Info
Table of Contents
-
Challenge
Enable the Source Repository API.
Use the API Library to find and enable the Google Cloud Source Repository API.
-
Challenge
Create a Source Repository.
Use the command:
gcloud source repos create gcpro_repo
-
Challenge
Clone the Source Repository.
Use the command:
gcloud source repos clone gcpro_repo
-
Challenge
Confirm the cloned repo.
Use the
ls
command to view the new cloned repo and thencd
into that folder. -
Challenge
Create an example file.
Use the
echo
command to create a new file. -
Challenge
Push the new content to the Source Repository repo.
- Configure two variables
user.email
anduser.name
. - Add the file:
git add greetings.txt
- Commit the file:
git commit -m "Committed initial file" greetings.txt
- Configure two variables
-
Challenge
Push the file from the master branch to origin.
Use the command:
git push origin master
-
Challenge
Confirm the operation.
- From the Source Repositories dashboard, click the
gcpro_repo
repo. - Click the
greetings.txt
file to review the contents.
- From the Source Repositories dashboard, click the
-
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.
-
Challenge
Create new repository.
- From the Source Repository dashboard, click Add repository.
- In the "Add a Repository" dialog, choose Connect external repository.
- On the Connect External Repository page, select the current project and then, from the Git Provider list, choose GitHub.
- When the Consent checkbox appears, select it.
- Choose Connect to GitHub.
- From the list of your repos, select one.
- Click Connect selected repository.
-
Challenge
Confirm the operation.
When the files of the repo are displayed, select one to open and confirm its contents.
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.