问题
Saw a sweet video on gcloud and wanted to give it a shot but was stymied at the start. I did the setup, downloaded the tools, ran gcloud auth login, all good. Tried to init a project and got an error I'm not sure how to fix.
$ gcloud init my-awesome-project-555
Initialized gcloud directory in [/Users/freddy/my-awesome-project-555/.gcloud].
Cloning [https://source.developers.google.com/p/my-awesome-project-555/r/default] into [default].
Initialized empty Git repository in /Users/freddy/my-awesome-project-555/default/.git/
fatal: remote error: 403 Forbidden
ERROR: Unable to initialize project [my-awesome-project-555], cleaning up [/Users/freddy/my-awesome-project-555].
ERROR: (gcloud.init) Could not fetch repository.
$
For good measure:
$ which git
/usr/local/git/bin/git
$ git --version
git version 1.7.12.1
$
I'm on a macbook air with OSX 10.9.2
Any ideas on what I may be doing wrong?
回答1:
The integration between gcloud auth and git only works for git clients version 1.8 and up. Please try updating your git client and try again. We will add a more clear error message for this in a future release. Thanks!
回答2:
The 403 indicates that you do not own my-awesome-project-555. You can use the cloud console (https://console.developers.google.com/project) to create a new project, and use that project ID with 'gcloud init'.
回答3:
If you continue to see 403 errors, you may need to obtain credentials to an existing repo. Obtain credentials by clicking the "Get credentials" button in the source repository settings. Save this in a .netrc file and try to commit again.
回答4:
In my case I changed the order of authenticated e-mails in ~/.netrc file just moving the desired account to the first line. I think it is a bug, since appears that only the first credential in the .netrc file is used when cloning or pushing.
回答5:
you don't have to put your project Id, you have to run the gcloud init first, after that you will be asked which service account or user account to init the configuration and then finish the configuration.
the 'gcloud init' no longer takes a PROJECT argument.
来源:https://stackoverflow.com/questions/23355252/trouble-using-gcloud-init