I have two different work folders in my computer one is in ~/Documents/work/companyA other is in ~/work/companyB. I wrote conditional gitconfig that is like
[includeIf "gitdir:~/Documents/work/companyA/"]
path = ~/Documents/work/companyA/.gitconfig
[includeIf "gitdir:~/Documents/work/companyB/"]
path = ~/Documents/work/companyB/.gitconfig
and the content of both of these files are like
[user]
name = companyAuser
email = [email protected]
[url "ssh://git@github-companyA/"]
insteadOf = https://github.com/
I know this file is being read and git@github-companyA is valid because when I run
git config user.email
ssh -T git@github-companyA
in a directory inside ~/Documents/work/companyA/ both of these commands work correctly.
i am using this config to "go get" from a private repository. Also when i put the URL rewrite command to ~/.gitconfig it works correct. How can i fix this
I misread your question: it is not a git question, it is actually a "go get + git" question.
The locations used by
go get
are located under theGOMODCACHE
directory, not under your working directory.Here is an illustration using
strace
on ago get github.com/spf13/cast
command (I simulated a private repo by settingGOPRIVATE=github.com/spf13/cast
) :Possible workarounds:
github.com/companyA/
instead of all ofgithub.com/
), you can set replacement urls globally, e.g:go get
commands; for example:GOMODCACHE
to a location under~/Documents/work/companyA/
when you work on a repo forcompanyA
note: this would lead to having several copies of your go cache on your disk