Search code examples
gitgcloudgoogle-cloud-source-repos

Clone Google Source Repository without gcloud


I am currently cloning the git repository present in Google Cloud Source repository using

gcloud source repos clone sample_repo --project=sample_project

Can I clone git repository present in Google Cloud Source Repository without using gcloud? Like,

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

Solution

  • gcloud does not do much when cloning, it only sets up credentials. In fact if you run

    $ gcloud source repos clone default --dry-run

    command (with --dry-run flag) you will see the git command gcloud runs under the hood:

    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 essentially just provides access token for the account. So if you have a way to get credentials you can wire in them into git this way.