使用用户 和 密码的形式访问git 私有仓库

git clone http[s] : //username:password | PAT@actual-git-url-for-the-repo
用户名、password 或者 PAT 中不要包含 @ 符号,如果有的话需要做url转义,比如@需要替换为%40,否则“实际的git url”就变成包含@符号;如果是PAT的话,用户名可以随便填

小技巧:用户及密码只要录入一次,在mac或者windows上都会记录下来,下次在访问有自己有权限的repository 就不用在录入用户名密码了;而linux上需要额外的配置才会自动保存密码

**在mac上 “钥匙串访问” **

windows “凭据管理器”

linux(以ubuntu为例)

vim ~/.gitconfig

修改配置文件,添加下面这一行。

[credential]
helper = store

1. gitlab

编辑个人资料 -> 访问令牌
填写令牌名称、到期时间、选择范围 勾选 read_repository、write_repository

项目设置 -> 访问令牌
填写令牌名称、到期时间、角色、选择范围 勾选 read_repository、write_repository

2. github

点击右上角用户头像,选择 settings -> Develpors settings -> Personal access tokens -> Generate new token
选中 repo,选择有效期(Expiration),输入 Note
Generate new token

3. gitee

点击头像选择设置 -> 私人令牌 -> gists

4. ads (azure devops)

点击头像旁边的 icon -> 选择 Personal access tokens

点击 New Token -> 勾选 Code 中的选项

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章