6

In the Google Source Repositories docs, it asks you to use git config credential.helper gcloud.sh to allow Git to authenticate

Recently, that's prevented me from using osxkeychain auth with GitHub - after adding that command, I get this error message when I attempt to pull from GitHub (on a repo whose only remotes are GitHub remotes):

git pull 

remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/[].git/'

Note that it doesn't even ask for my username & password again; it immediately refuses to connect

If I remove the gcloud credential.helper from git config, I can re-authenticate with GitHub (though need to type my username & password in again)

I'm using git version 2.15.1 and gcloud:

Google Cloud SDK 183.0.0
alpha 2017.09.15
beta 2017.09.15
bq 2.0.27
container-builder-local
core 2017.12.08
datalab 20171003
gcloud
gsutil 4.28
kubectl
Maximilian
  • 7,512
  • 3
  • 50
  • 63

2 Answers2

12

The problem here is that the instructions overwrite a possible existing credential helper. To restrict the credential helper to only apply to Google Source Repositories run:

git config credential.'https://source.developers.google.com'.helper gcloud.sh

or change in your .git/config

[credential]
        helper = gcloud.sh

to

[credential "https://source.developers.google.com"]
        helper = gcloud.sh
Robert
  • 296
  • 2
  • 6
0

You need to set credential helper for Google Cloud repository only, not system wide.

Also for github consider using ssh-keys instead of username/password: https://help.github.com/articles/connecting-to-github-with-ssh/

cherba
  • 8,681
  • 3
  • 27
  • 34
  • How do you set it for the Google Cloud repo only? The default of `git config` is `--local` anyway, though it's a repo that has an origin on both GH & Google Cloud so needs to exist in `--local` – Maximilian Jan 09 '18 at 16:19
  • SSH is possible, though it's a hack around the issue, and prevents using a username & password for GitHub – Maximilian Jan 09 '18 at 16:20