Cloning a Repository

This topic describes how to clone the contents of a repository from Cloud Source Repositories to your local machine.

Before you begin

You must have a repository in Cloud Source Repositories. To create a new repository, see Creating an Empty Repository.

Using Google Cloud SDK

Console

  1. Open the My Source view in the console:

    Open the Source View in the Console

  2. Click View All Repositories, located in the top right corner.

    The All Repositories screen opens.

  3. Hover over the repository you want to clone.

  4. Click the Plus (+) icon.

    The Cloning Your Repository screen opens.

  5. Select the Google Cloud SDK option.

  6. Follow the on-screen instructions to clone your repository.

Command line

  1. Open a terminal window.

  2. Install the Google Cloud SDK.

  3. Type the following command to provide your authentication credentials.

    gcloud init
    
  4. Type the following command to clone your repository.

    gcloud source repos clone [REPOSITORY_NAME] --project=[PROJECT_NAME]
    

    Where:

    • [REPOSITORY_NAME] is the name of your repository
    • [PROJECT_NAME] is the name of your project

Using manually generated credentials

If you are not using the Google Cloud SDK, you can clone a repository using manually generated credentials.

Console

  1. Open the My Source view in the console:

    Open the Source View in the Console

  2. Click View All Repositories, located in the top right corner.

    The All Repositories screen opens.

  3. Hover over the repository you want to clone.

  4. Click the plus icon.

    The Cloning Your Repository screen opens.

  5. Select the Manually generated credentials option.

  6. Follow the on-screen instructions to clone your repository.

Command line

  1. Generate and store your Git credentials.

  2. Open a terminal window.

  3. Type the following command:

    git clone https://source.developers.google.com/p/[PROJECT_NAME]/r/[REPOSITORY_NAME]
    

    Where:

    • [PROJECT_NAME] is the name of your project
    • [REPOSITORY_NAME] is the name of your repository

What's next

After you clone a repository to your local machine, you can:

  • Explore the quickstarts to learn how Cloud Source Repositories integrates with other Google Cloud Platform services.
Was this page helpful? Let us know how we did:

Send feedback about...

Cloud Source Repositories