1

When I call

gcloud source repos clone my-service --project=tools-project

inside the Cloud Shell I can successfully clone the my-service repository from Google Source Repository.

However when I call the same command on MacOS I get the following error:

Cloning into '/Users/XXX/my-service'...
fatal: remote error: PERMISSION_DENIED The caller does not have permission
ERROR: (gcloud.source.repos.clone) Command '[u'git', u'clone', u'https://source.developers.google.com/p/tools-project/r/my-service', u'/Users/XXX/my-service', u'--config', u'credential.helper=', u'--config', u'credential.helper=!gcloud auth git-helper --account=XXX@XXX.io --ignore-unknown $@']' returned non-zero exit status 128

I am logged in with the same user on the website and on the computer. Where could the error be?

Harold L. Brown
  • 8,423
  • 11
  • 57
  • 109
  • 1
    What credential helper is configured: `git config --list --system`? Clear the credential helper: `git config --system --unset credential.helper`. Set credential helper for MacOS: `git config credential.helper gcloud.sh` – John Hanley Aug 01 '19 at 20:37
  • Can you try running `gcloud init` to create a new configuration and set up local authentication? Furthermore, ensure that the correct account was used by running `gcloud auth login` and check in your IAM permissions that the account you are using has the proper permissions to pull code from the Cloud Source Repositories. – JKleinne Aug 01 '19 at 21:27
  • @JohnHanley When I type `git config --list --system` I find nothing about credentials. When I type `git config credential.helper gcloud.sh` I get the error message `fatal: not in a git directory`. I can't clone the repo, hence I am not inside a Git directory. – Harold L. Brown Aug 01 '19 at 21:31
  • @JKleinne I have already tried it with a new configuration. That didn't work either. I am logged in as the right user. Since I can pull code inside the cloud shell I guess the permissions should be fine. – Harold L. Brown Aug 01 '19 at 21:33
  • Use `git config --global credential.helper gcloud.sh` to enable the option for all git projects. https://git-scm.com/docs/gitcredentials – John Hanley Aug 01 '19 at 21:35
  • @JohnHanley I did that and I'm still receiving the same error. – Harold L. Brown Aug 01 '19 at 21:37
  • The only thing left is that you did not install and configure `git` correctly on your system (or something broke later). Note global commands are not part of a .git project, so I don't know how you were able to get the same error message. Make sure that you are using the lastest version of Git and follow this setup: https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup Then run `gcloud init`. – John Hanley Aug 01 '19 at 21:40

1 Answers1

0

I have appended a .bak to the following files:

 - .git-credentials 
 - .gitconfig 
 - .gitcookies

Now it is working.

P.S.: In the end I have deleted the files.

Harold L. Brown
  • 8,423
  • 11
  • 57
  • 109