使用 gcloud 的凭据助手访问 Google 源存储库会阻止 osxkeychain 工作

Using gcloud's credential helper to access Google Source Repositories prevents osxkeychain from working

Google Source Repositories docs 中,它要求您使用 git config credential.helper gcloud.sh 以允许 Git 进行身份验证

最近,这阻止了我将 osxkeychain auth 与 GitHub 一起使用 - 添加该命令后,当我尝试从 GitHub 中提取时收到此错误消息(在一个仅包含遥控器是 GitHub 遥控器):

git pull 

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

请注意,它甚至不再询问我的用户名和密码;它立即拒绝连接

如果我从 git 配置中删除 gcloud credential.helper,我可以使用 GitHub 重新进行身份验证(尽管需要再次输入我的用户名和密码)

我正在使用 git version 2.15.1gcloud:

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

您只需要为 Google 云存储库设置凭据助手,而不是系统范围的。

另外 github 考虑使用 ssh-keys 而不是 username/password:https://help.github.com/articles/connecting-to-github-with-ssh/

这里的问题是指令覆盖了可能存在的凭证助手。限制凭据助手仅适用于 Google 个源存储库 运行:

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

或更改您的 .git/config

[credential]
        helper = gcloud.sh

[credential "https://source.developers.google.com"]
        helper = gcloud.sh