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
git clone [email protected]:company/repo.git
to clone the repo to ~/Desktop/BitBucket/Company
directory.GOPRIVATE="bitbucket.org/company/*"
includeIf
. If I replace .gitconfig with company .gitconfig it works fine. But I need to manage multiple accounts...git config --get user.name
(inside the repo) returns My Name
. So there is a problem with go 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
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.
gitconfig is used to store a per-user configuration as fallback values for the . git/config file. The file /etc/gitconfig can be used to store a system-wide default configuration. The configuration variables are used by both the Git plumbing and the porcelains.
The reason they can't find gitconfig is simply because it's nowhere to be found. When developers install Git, the various Git configuration files won't automatically create. Files like gitconfig and . gitconfig are only created when they're first used.
If you're using go get
to clone a repository, be aware that the gitdir:
and gitdir/i:
patterns don't match a repository that's being cloned. That's because the pattern matches directories that are .git
directories, and when you're cloning, that .git
directory hasn't been created yet.
You could try placing a directive like this into your config instead:
[url "[email protected]:company/"]
insteadOf = https://bitbucket.org/company/
and then setting up a non-work key for Bitbucket if you need to clone other (public) repositories.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With