Quickstart for Linux

Google Cloud Source Repositories provides Git version control to support collaborative development of an application or service, such as those that run on App Engine and Compute Engine.

This page shows you how to create a new repository in Cloud Source Repositories.

Before you begin

  1. Select or create a GCP project.

    Go to the Manage resources page

  2. Install Git.
  3. Install and initialize the Cloud SDK.

Create a new repository

From a terminal window, create a new Google Cloud Platform (GCP) repository, named hello-csr, using the gcloud source repos create command:

gcloud source repos create hello-csr

Clone a repository

Clone the contents of the GCP repository into a local Git repository using the gcloud source repos clone command:

gcloud source repos clone hello-csr

Push to the Cloud Source Repository

In this section you create a file in your local Git repository and then push that file to Cloud Source Repositories.

  1. Create a file in your local Git repository:

       echo "Hello World!" > myfile.txt
    
  2. Add the file:

       git add myfile.txt
    
  3. Commit the file:

       git commit -m "First file using Cloud Source Repositories" myfile.txt
    
  4. Add the contents of the local Git repository to Cloud Source Repositories using the git push command:

       git push origin master
    

    Git pushes myfile.txt from the master branch to the origin remote. You should see output similar to the following:

       Counting objects: 21, done.
       Delta compression using up to 6 threads.
       Compressing objects: 100% (20/20), done.
       Writing objects: 100% (21/21), 9.76 KiB | 0 bytes/s, done.
       Total 21 (delta 5), reused 0 (delta 0)
       remote: Storing objects: 100% (21/21), done.
       remote: Processing commits: 100% (6/6), done.
       To https://source.developers.google.com/p/example-project-1244/r/repo-name
        * [new branch]      master -> master
    

Browse files in the GCP repository

  1. Open the Source view in the GCP Console:

    Open the Source View in the Console

  2. Browse to the myfile.txt you pushed to the repository.

    The console shows the files in the master branch at the most recent commit.

    View repository files

View a file in the GCP repository

  1. Open the Source view in the GCP Console:

    Open the Source View in the Console

  2. Click myfile.txt to view its contents in the source code browser.

    View repository file

Clean up

To delete the repository you created:

  1. Open the source view in the GCP Console:

    Open the Source View in the Console

  2. Click the More button More button next to the repository you want to delete.

    Create Repository button

  3. Select Delete.

  4. When prompted for the repository name, enter hello-csr and then click Delete.

What's next

Send feedback about...

Cloud Source Repositories