Gitlab个人访问令牌-用于无缝克隆/拉/推的令牌存放位置



有人能告诉Gitlab PAT-个人访问令牌放在哪里吗?

正在下载git::https://gitlab.com/mycompany/myproject.git?ref=v0.0.1-无法下载-我无法更改URL,因为它在项目回购中是固定的。

我试着在我的git-config--global中设置它gitlab.accesstoken=abcdef1233TVHEPkNxyz

也作为环境变量TOKEN=abcdef1233TVHEPkNxyzPRIVATE_TOKEN=abcdef1233TVHEPkNxyz

有什么建议吗?

基本上我们需要:

  1. 生成PAThttps://gitlab.com/profile/personal_access_tokens[根据要求授予权限]
  2. git clone https://oauth2:abcdef1233TVHEPkNxyz@gitlab.com/mycompany/myproject.git?ref=v0.0.1

但是,如果我们不能将url从:git::https://gitlab.com/mycompany/myproject.git?ref=v0.0.1更改为上述格式,或者我们想避免每次克隆repo或使用GitLab API时输入令牌,我们需要执行以下操作:

  1. 设置凭据存储,例如在Ubuntu上:

    `sudo apt-get install libsecret-1-0 libsecret-1-dev`
    `sudo make --directory=/usr/share/doc/git/contrib/credential/libsecret`
    `git config --global credential.helper /usr/share/doc/git/contrib/credential/libsecret/git-credential-libsecret`
    
  2. Git克隆一个http url:

    `git clone https://gitlab.com/mycompany/myproject.git?ref=v0.0.1`
    

当提示输入密码时,请改用PAT。PAT将在libsecret存储中默认存储15分钟。使用git config --global credential.helper 'cache --timeout=1800'更改超时持续时间。

参考:https://www.softwaredeveloper.blog/git-credential-storage-libsecret

最新更新