简体   繁体   中英

How to clone a private git repository using a initialization shell script

I'm start working with google compute engine and trying to automate the VM initialization process. On startup the VM should clone a private git repo on bitbucket and run the aplication.

So, if it was a public repo would look like this:

git init myapp
cd myapp
git pull https://me@bitbucket.org/me/myapp.git

How do I do if I want to keep my code private? Should I download a SSH Key first? If so, how do I do this?

I also tried cloning it to the cloud repository, but also asking for credentials. Is this a better aproach?

Looking through the Google Repository docs I found that you can get access to the project repository on google cloud using a helper from the Google Cloud SDK running the command line:

git config credential.helper gcloud.sh

But as the SDK is already installed in all GCE instances, so just:

git init myapp
cd myapp
git config credential.helper gcloud.sh
git pull https://source.developers.google.com/p/<project-id>/r/default

if cloning into a local machine, just install the SDK

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM