I clone a repository with git clone which has a dependency from another private repo. Inside current repo I try to go get that dependency (go get -u ./...) and it throws me an error:
fatal: could not read Username for 'https://bitbucket.org': terminal prompts disabled
Info
- I used
git clone [email protected]:company/repo.gitto clone the repo to~/Desktop/BitBucket/Companydirectory. - I have
GOPRIVATE="bitbucket.org/company/*" - Everything works without
includeIf. If I replace .gitconfig with company .gitconfig it works fine. But I need to manage multiple accounts... - The command
git config --get user.name(inside the repo) returnsMy Name. So there is a problem withgo get
My main .gitconfig file (in $HOME directory):
[includeIf "gitdir/i:~/Desktop/BitBucket/Company/"]
path = ~/.git/BitBucket/Company/.gitconfig
My .gitconfig file (for company repo $HOME/.git/BitBucket/Company/.gitconfig):
[user]
name = My Name
email = [email protected]
[url "[email protected]:"]
insteadOf = https://bitbucket.org/
My ssh config file ($HOME/.ssh/config):
Host my-name.bitbucket.org
Hostname bitbucket.org
PreferredAuthentications publickey
IdentityFile ~/.ssh/keys/BitBucket/my_name/id_rsa
What is my mistake?
I also found this article: https://medium.com/easyread/today-i-learned-fix-go-get-private-repository-return-error-terminal-prompts-disabled-8c5549d89045. You can check the first comment:
FYI, this dont work when using .gitconfig that references a custom .gitconfig-custom. It has to live in ~/.gitconfig….. man that was frustrating.
I tried to move company .gitconfig to home directory (+ renamed it .gitconfig-company). Nothing works.
If you're using
go getto clone a repository, be aware that thegitdir:andgitdir/i:patterns don't match a repository that's being cloned. That's because the pattern matches directories that are.gitdirectories, and when you're cloning, that.gitdirectory hasn't been created yet.You could try placing a directive like this into your config instead:
and then setting up a non-work key for Bitbucket if you need to clone other (public) repositories.