Skip to content

Instantly share code, notes, and snippets.

@rodkranz
Last active July 27, 2022 13:15
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rodkranz/c235df550bc279f7d44c98e279dcf265 to your computer and use it in GitHub Desktop.
Save rodkranz/c235df550bc279f7d44c98e279dcf265 to your computer and use it in GitHub Desktop.
Go Get from private repository

I had a problem with go get using private repository on gitlab from our company. I lost a few minutes trying to find a solution.... and I did find one:

  1. You need to get a private token at:

    https://gitlab.mycompany.com/profile/account

  2. Configure you git to add extra header with your private token:

    $ git config --global http.extraheader "PRIVATE-TOKEN: YOUR_PRIVATE_TOKEN"

  3. Configure your git to convert requests from ssh to http:

    $ git config --global url."git@gitlab.mycompany.com:".insteadOf "https://gitlab.mycompany.com/"

  4. Finally you can use your go get normally

    $ go get gitlab.com/company/private_repo

@andrealeixo
Copy link

Awesome! Works like a charm! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment