13

Pulling from an existing clone

git pull

or cloning Google cloud repository with gcloud

gcloud source repos clone default my_repo

produces the following dialog box: enter image description here

How do I configure git so that it uses gcloud credentials automatically?

cherba
  • 8,681
  • 3
  • 27
  • 34

2 Answers2

21

If you run

C:\> git config --list --system
credential.helper=manager

and get a setting for credential.helper like above, it will have precedence over gcloud installed credential helper.

You can unset it via (possibly as administrator)

C:\> git config --system --unset credential.helper

Now

C:\> gcloud source repos clone default my_repo

should work and

C:\> cd my_repo
C:\my_repo> git config --list

should display

credential.helper="gcloud.cmd"
cherba
  • 8,681
  • 3
  • 27
  • 34
  • 1
    umm.. are there side effects to removing the --system credential.helper? – Brett Caswell Jul 02 '16 at 22:05
  • 1
    More recent git versions for windows started to set credential helper to Microsoft credential manager https://github.com/Microsoft/Git-Credential-Manager-for-Windows by default. If you working with Visual Studio or otherwise want to use this manager you can still set it for the repository you are working with, just don't use --system flag. That should remain unset. – cherba Jul 04 '16 at 22:38
  • I had something similar going on using OS X and Android Studio/Google Cloud Repository. It appears that there was a conflict with using the authentication within the .netrc Git file as well with the gcloud credential.helper. I am still investigating, but after deleting the .netrc file I was able to get authentication working. I hope this information is useful for someone else getting these types of errors. – GregM Jan 12 '17 at 22:28
4

In my case, I opened and modified 'C:\Program Files\Git\mingw64\etc\gitconfig':

[credential]
    helper = gcloud.cmd
    old = manager

so that I had some notion of retention with my git config modifications..

Brett Caswell
  • 1,486
  • 1
  • 13
  • 25
  • 1
    You do not really want to set this helper globally or system wide. Just set it on the repository you are working with. Note that when you run `gcloud source repos clone default my_repo` it sets the helper just for the repository being cloned. – cherba Jul 04 '16 at 22:41
  • It worked for me, should hv installed gcloud fr single user.. wouldn't hv faces this problem – Akanksha Gaur Sep 03 '16 at 16:06
  • 2
    you could do this with the command `git config --add credential.helper "gcloud.cmd"` – Bernardo Dal Corno Oct 14 '16 at 23:26