Correct global git config for personal access tokens in GitHub

Viewed 6562

I'm trying to RUN go get github.com/<user>/<repo> inside docker. I want to do it with GitHub's personal access token. To do that I tried running

git config --global url.”https://${GIT_TOKEN}@github.com/".insteadOf “https://github.com/"

and

git config --global url.”https://${GITHUB_USER}:${GIT_TOKEN}@github.com/".insteadOf “https://github.com/"

both of the commands are throwing similar error

error: invalid key: url.”https://<pa_token>@github.com/.insteadOf “https://github.com/

Can someone tell me what is the correct way to do it using GitHub PAT?

1 Answers

I think the issue is with the quotes.

The correct command is

git config --global url."https://${username}:${access_token}@github.com".insteadOf "https://github.com"
Related