How to Upload Source Code Google Developer
Create a code repository in Cloud Source Repositories
In this quickstart, yous create a repository in Deject Source Repositories. Y'all then commit the lawmaking for a modest Python app that you can deploy after to App Engine.
Deject Source Repositories are private Git repositories hosted on Google Cloud. These repositories let you develop and deploy an app or service in a space that provides collaboration and version control for your code.
Before y'all brainstorm
- Sign in to your Google Cloud business relationship. If yous're new to Google Cloud, create an account to evaluate how our products perform in existent-globe scenarios. New customers also go $300 in free credits to run, test, and deploy workloads.
-
In the Google Cloud Panel, on the project selector page, select or create a Google Cloud project.
Go to project selector
-
Make sure that billing is enabled for your Deject projection. Learn how to check if billing is enabled on a project.
-
In the Google Deject Console, on the project selector page, select or create a Google Cloud project.
Go to projection selector
-
Brand sure that billing is enabled for your Cloud project. Learn how to check if billing is enabled on a project.
- Install and initialize the Google Cloud CLI.
- Verify that you lot have the latest version of Git.
- If you have not configured your user credentials in Git, follow the start time setup instructions.
- Enable the Cloud Source Repositories API.
Enable the Deject Source Repositories API
Create a repository
In a concluding window, use the gcloud source repos create
command to create a Google Deject repository named hello-globe
:
gcloud source repos create hi-world
Clone a repository
Utilize the gcloud source repos clone
command to clone the contents of the Google Cloud repository into a local Git repository:
gcloud source repos clone hello-globe
Create a " Howdy, Earth!" script
Create a Python script that prints Hello, Globe!
in a browser window.
-
Go to your
how-do-you-do-world
repository. -
Using a text editor, create a file named
main.py
, and so paste the following lawmaking:#!/usr/bin/env python import webapp2 form MainHandler(webapp2.RequestHandler): def get(self): cocky.response.write('Hello, World!') app = webapp2.WSGIApplication([ ('/', MainHandler) ], debug=True)
Create an app.yaml file
Create an app.yaml
file that contains the configuration information yous need to deploy your code to App Engine.
-
Go to your
hello-world
repository. -
Using a text editor, create a file named
app.yaml
, and and then paste the post-obit configuration information:runtime: python27 api_version: ane threadsafe: yep handlers: - url: .* script: main.app libraries: - name: webapp2 version: "2.five.2"
Push button to Deject Source Repositories
Push the files you just created into Cloud Source Repositories.
-
In a terminal window, get to your
hello-world
directory:cd howdy-world
-
Add together the files:
git add together .
-
Commit the files to the repository with a comment describing the history of this action:
git commit -g "Add Hello World app to Cloud Source Repositories"
-
Using the
git push button
command, add together the contents of the local Git repository to Cloud Source Repositories:git push button origin master
Git pushes the files from the
master
branch to theorigin
remote. Output similar to the following is displayed:Counting objects: 21, washed. Delta compression using up to 6 threads. Compressing objects: 100% (20/20), done. Writing objects: 100% (21/21), ix.76 KiB | 0 bytes/due south, done. Total 21 (delta 5), reused 0 (delta 0) remote: Storing objects: 100% (21/21), washed. remote: Processing commits: 100% (six/6), done. To https://source.developers.google.com/p/example-project-1244/r/repo-name * [new branch] main -> master
View files in the repository
-
In the Google Cloud Console, open Cloud Source Repositories.
Open Cloud Source Repositories
-
Click the proper name of the
hi-earth
repository that y'all created. -
Go to the files you pushed to the repository.
The GCP Console shows the files in the
principal
branch at the most recent commit. -
In the Files list, click a file to view its contents.
Y'all can also view the files by using Deject Shell.
Clean up
With your howdy-earth
repository in identify, you can proceed to explore Cloud Source Repositories. For a complete list of bachelor quickstarts, run into Quickstarts.
If y'all're finished with this repository, you lot can delete it by following these steps.
-
In the GCP Panel, open the All repositories page for Cloud Source Repositories.
Open Cloud Source Repositories
-
Agree the pointer over the repository you want to delete and click Settings .
The General settings page opens.
-
Click Delete this repository .
The Remove repository dialog opens.
-
Type the proper noun of the repository you want to delete.
-
Click Delete.
What's next
- Learn more well-nigh setting up a repository.
- Learn more than well-nigh cloning a repository.
- Learn how to add a repository every bit a Git remote.
- Learn how to connect a repository hosted on GitHub or Bitbucket.
Source: https://cloud.google.com/source-repositories/docs/create-code-repository
Post a Comment for "How to Upload Source Code Google Developer"