go get results in 'terminal prompts disabled' error for github private repo

前端 未结 7 1464
余生分开走
余生分开走 2020-11-30 16:50

I created the private repo examplesite/myprivaterepo using the Github UI from my browser.

Then I went to my go directory (on the desktop) and cloned it:



        
7条回答
  •  有刺的猬
    2020-11-30 16:57

    1st -- go get will refuse to authenticate on the command line. So you need to cache the credentials in git. Because I use osx I can use osxkeychain credential helper.

    2nd For me, I have 2FA enabled and thus could not use my password to auth. Instead I had to generate a personal access token to use in place of the password.

    1. setup osxkeychain credential helper https://help.github.com/articles/caching-your-github-password-in-git/
    2. If using TFA instead of using your password, generate a personal access token with repo scope https://github.com/settings/tokens
    3. git clone a private repo just to make it cache the password git clone https://github.com/user/private_repo and used your github.com username for username and the generated personal access token for password.
    4. Removed the just cloned repo and retest to ensure creds were cached -- git clone https://github.com/user/private_repo and this time wasnt asked for creds.

      1. go get will work with any repos that the personal access token can access. You may have to repeat the steps with other accounts / tokens as permissions vary.

提交回复
热议问题