July 2, 2016

Access Google Cloud Source Repositories from Visual Studio

Cloud Source Repositories (CSR) provides support for multiple Git repositories for each project. To log into your CSR repos from within Visual Studio, you’ll need credentials that Visual Studio expects, i.e. a username and password pair. CSR calls these manually generated credentials” (as opposed to the Google Cloud SDK generated credentials which are the default).

Manually Generated Credentials

To get manually-generated credentials, do the following:

  • Go to the Development” section in the Google Cloud Console.

  • Select the Source Code section and choose the repo that you’d like to access locally from the drop-down. Then, open the drop-down again and select Clone repository”.

  • Change the preferred authentication method to Manually generated credentials”.

  • Copy the URL starting with https://source.developers.google.com into your clipboard and save it for later. One easy way to do this is to use the Copy button to put the entire git clone command into your clipboard and then trim it to just the URL portion.

  • Click Generate and store your Git credentials” (and not the OK button).

  • From the browse window that pops up, gather the Git password (which goes along with the email you used to authenticate). You can ignore the instructions about putting a command into your .netrc file, since Visual Studio will ask you for your username/password pair directly.

Logging Into CSR from Visual Studio

Now that you have your CSR Git URL, username and password, you have what you need to use your CSR repo from Visual Studio.

  • To start, choose View | Team Explorer in Visual Studio.

  • In the Local Git Repositories section, choose the Clone option and add the Git URL for your CSR repo, choose a local directory and press the Clone button.

  • Visual Studio will prompt you for the username and password.

The username is the email address you used to generate the Git password previously. The password is the one you generated when you asked for manually generated credentials.

At this point, you can edit your files into Visual Studio normally and use the Team Explorer to see the files that have changed, look at diffs, commit the changes, etc.