1.获取gitlab的access token
打开所需要Token的项目
然后Setting --> CI/CD --> Genneral pioelines settings --> Expand --> Runner token
![](https://img.haomeiwen.com/i14043475/d0f770a96705d163.png)
git config --global http.extraheader "PRIVATE-TOKEN: YOUR_PRIVATE_TOKEN"
把Runner token文本框中的内容替换上面的YOUR_PRIVATE_TOKEN
2.为GitLab帐号添加SSH keys
cat ~/.ssh/id_rsa.pub
把上述内容添加到gitlab中
![](https://img.haomeiwen.com/i14043475/0ab010f2a829e1c2.png)
![](https://img.haomeiwen.com/i14043475/8b351a069dca621b.png)
![](https://img.haomeiwen.com/i14043475/c2aff782168be8e4.png)
3.配置git将请求从ssh转换为http
git config --global url."git@gitlab.com:groupName/projectName.git".insteadOf "https://gitlab.com/groupName/projectName.git"`
4.拉取
go get -u -v gitlab.com/groupName/projectName
网友评论