> go get github.com/myorg/private-repo
# cd .; git clone https://github.com/myorg/private-repo mygopath/src/github.com/myorg/private-repo
Cloning into 'mygopath/src/github.com/myorg/private-repo'...
fatal: could not read Username for 'https://github.com': terminal prompts disabled
package github.com/myorg/private-repo: exit status 128
- You are on a Mac
- You have installed git via homebrew or xcode command line tools
git config --global credential.helper osxkeychain
If you don't have two-factor auth on your Github account, then skip to #3
Go to Github.com > Settings > Developer Settings > Personal Access Tokens and click "Generate new token". Select all the permissions, or don't, it's up to you... but it will definitely work if you select all of them. Copy the token and use it for your password in the next step – Github won't show you the token again.
Pick any private repo you have access to and copy its https
clone URL. cd
to somewhere where you can clone it and run git clone
with that URL. You will be prompted for your username and password – use your personal access token as your password if you have two-factor auth. The osxkeychain
credential helper will save them to your keychain.
Run your go get ...
command again and it should work because the osxkeychain
helper will read your username and password from your keychain. It might seem to hang for a bit while it reads it (or maybe it hung for me for some other reason idk).