在没有 gcloud 的情况下克隆 Google 源存储库

Clone Google Source Repository without gcloud

我目前正在使用

克隆 Google Cloud Source 存储库中的 git 存储库
gcloud source repos clone sample_repo --project=sample_project

我可以在不使用 gcloud 的情况下克隆存在于 Google Cloud Source Repository 中的 git 存储库吗? 喜欢,

git clone https://source.developers.google.com/p/sample_project/r/sample_repo

gcloud 在克隆时不会做太多事情,它只会设置凭据。事实上,如果你 运行

$ gcloud source repos clone default --dry-run

命令(带有 --dry-run 标志)您将看到 git 命令 gcloud 运行s 在幕后:

git clone https://source.developers.google.com/p/YOUR_PROJECT/r/default \ --config credential.helper='!gcloud auth git-helper --account=YOUR_ACCOUNT --ignore-unknown $@'

gcloud credential helper 本质上只是为帐户提供访问令牌。因此,如果您有办法获得凭据,您可以通过这种方式将它们连接到 git。