Git 免密拉取

13次阅读
一条评论

免密拉取用的比较少,基本都是公司项目 gitlab,配置一次就基本不再配置,或者在 git 上建立的私有仓库,然后配置私钥,放到仓库上。基本有这么几种方式:

使用 SSH 密钥认证

  • 本地建立 SSH 密钥:ssh-keygen -t ed25519 -C "your_email@example.com"(你的邮箱地址)
  • 复制私钥:`cat ~/.ssh/id_ed25519.pub` 或者 `cat ~/.ssh/id_rsa.pub`
  • 进入仓库设置 –>ssh 密钥:将密钥保存
  • 更新拉取方式:例如:git remote set-url origin git@gitee.com:username/repo.git (从 ssh 克隆获取)

使用 Git 凭证存储

  • 使用 Git 内置的凭证存储:git config –global credential.helper store 下次输入密码后会被保存到 ~/.git-credentials
  • 或者使用内存缓存(安全一些):
git config --global credential.helper cache
git config --global credential.helper 'cache --timeout=3600'  # 设置缓存时间 (秒)

首次操作时输入一次账号密码:git pull https://gitee.com/ 用户名 / 仓库名.git

输入用户名和密码后会自动保存,后续无需重复输入

正文完
 0
评论(一条评论)
验证码
2025-08-12 00:51:47 回复

还有其他方式

 Windows  Chrome  内网IP