I use a workaround with
GITHUB_TOKEN
to solve this.- Generate
GITHUB_TOKEN
here export GITHUB_TOKEN=xxx
git config --global url."https://${GITHUB_TOKEN}:x-oauth-basic@github.com/mycompany".insteadOf "https://github.com/mycompany"
I wrote up a solution for this on Medium: Go Modules with Private Git Repositories.
The way we handle it is basically the same as the answer above from Alex Pliutau, and the blog goes into some more detail with examples for how to set up your git config with tokens from GitHub/GitLab/BitBucket.
The relevant bit for GitLab:
git config --global \
url."https://oauth2:${personal_access_token}@privategitlab.com".insteadOf \
"https://privategitlab.com"
#or
git config --global \
url."https://${user}:${personal_access_token}@privategitlab.com".insteadOf \
"https://privategitlab.com"
I hope it's helpful.
I use ls-remote git command to help resolve private repo tags and go get after it.
$ go env GO111MODULE=on
$ go env GOPRIVATE=yourprivaterepo.com
$ git ls-remote -q https://yourprivaterepo.com/yourproject.git
$ go get
I try to fix this issue and then solved with this...
you need to set up 3 ENV on your local machine
GONOPROXY=privategitlab.company.com
GONOSUMDB=privategitlab.company.com
GOPRIVATE=privategitlab.company.com
this will solved your issue
At first you should set GOPRIVATE
go env -w GOPRIVATE=privategitlab.com
then you have two methods:
first method:
git config --global url."https://{userName}:{access_token}@privategitlab.com".insteadOf "http://privategitlab.com"
second method:
update or create ~/.netrc file and put below line and save it
machine privategitlab.com login {username} password {access_token}
I prefer the second method because if you have group and subgroup in git, first method don't work