Configure Multiple git credentials when using Google Cloud SDK for Google Cloud Repositories

As the long title explains, this is a short code to help out fellow developers who are dipping their toes in git and specifically while using Google Source Repositories.

I am facing a common scenario where I use Google Cloud Repositories for both office purpose and personal purpose. But I am fairly new to git and when using global credentials the previously configured user doesn’t have access to the present repository.

Here is what I did. I created a new configuration using gcloud init

The edit the git config with the command

git config –edit

Add the following line in the credentials section below helper

[credential "https://source.developers.google.com"]
	helper = gcloud.cmd
	username = [email protected]

Adding the line with username and then using the actual email with respect to your user id of the repository simply works.

If git gurus out there see this, please suggest whether you can think of a better way for the problem.

Leave a Reply

Your email address will not be published. Required fields are marked *