2018年10月5日 星期五

如何在 golang 裡面引用 gitlab private repo

參考文章:https://stackoverflow.com/questions/27500861/whats-the-proper-way-to-go-get-a-private-repository

原文是用 gitlab.company.com 當範例,這邊改成一般帳號並加入一些說明。

  1. 先連到帳號頁面產生 private access token,權限需要有 read_repository
    https://gitlab.com/profile/account
  2. 修改 git global 設定將剛剛產生的 token 加入 http.extrahdeader 參數:
    $ git config --global http.extraheader "PRIVATE-TOKEN: 你的access token"
  3. 修改 git global 設定將github 的 ssh 連線方式替換成 https:
    $ git config --global url."git@gitlab.com:你的帳號".insteadOf "https://gitlab.com/你的帳號"
  4. 完成後就可以正常使用 go get 下載 private repo :
    $ go get gitlab.com/slv922/private_repo

沒有留言:

張貼留言

如何在 golang 裡面引用 gitlab private repo

參考文章:https://stackoverflow.com/questions/27500861/whats-the-proper-way-to-go-get-a-private-repository 原文是用 gitlab.company.com 當範例,這邊改成一般帳號...