我正在尝试获取对现有 Google Developers Console (GDC) 项目的嵌入式 git 存储库的访问权限。 GDC 在 -SOURCE CODE-Releases 下显示 git 存储库。我按照官方 gcloud 安装说明进行了操作:
gcloud auth login /* pulls up browser and does authentication just fine */
gcloud config set project <project>
gcloud init <project>
后者总是产生以下结果(将实际项目名称替换为“鱼骨”):
$gcloud init fishbone
Initialized gcloud directory in [/Users/dummy/Workspace/fishbone/.gcloud].
Cloning [https://source.developers.google.com/p/fishbone/r/default] into [default].
Initialized empty Git repository in /Users/dummy/Workspace/fishbone/default/.git/
fatal: remote error: Invalid username/password.
You may need to use your OAuth token password; Note that generated google.com passwords are not compatible with private repositories
ERROR: Unable to initialize project [fishbone], cleaning up [/Users/dummy/Workspace/fishbone].
ERROR: (gcloud.init) Could not fetch repository.
只有在第一次安装 SDK 时(现在重试了不止一次),我记得 gcloud init 要求输入用户名。以后再也不会了。 Mac OS X 10.9.3 和:
$git --version
$git version 1.8.5.2 (Apple Git-48)
我知道 this related gcloud init issue ,但不是这个。非常感谢帮助。
最佳答案
转到 https://console.developers.google.com/project/your-project-id > 源代码 > 浏览 > 找到这一行:“或者,您可以通过点击此链接手动生成 Git 凭据,而不是使用 Google Cloud SDK 来管理您的身份验证。” > 点击“following this link”,你可以看到你的git密码。正如您在错误中看到的那样,谷歌密码与私有(private)存储库不兼容。现在您可以:
- 使用上面的 gmail 和 git 密码克隆存储库。
- 或者在您的主文件夹中创建 .netrc 文件并添加:“machine source.developers.google.com login your-email@gmail.com password 1/abxxxxxxxxxxxxxxxxxxxxxxx”到此文件。它不会再次请求您的密码。
关于macos - gcloud init 因用户名/密码无效而失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25142914/