在linux下执行git clone、git pull 、git push等操作免密

1. 通过ssh密钥实现

ssh-keygen -t rsa -C "你的邮箱" -f "自己定义的目录" 

打开: id_rsa.pub ,将文件内容复制到 gitlab 设置页:ssh密钥配置。

2. 通过配置.git-credential配置免密输入

可以进行设置,这样在输入过一次密码之后,以后就不需要每次都输入密码了。

打开终端:
输入:

touch ~/.git-credentials

如果手工在其中加入:

https:{username}:{password}@***.com

那么第一次访问git地址,也不用输入密码了。

再输入:

git config --global credential.helper store

这一步会在用户目录下的.gitconfig文件最后添加:

[credential]
helper = store

3. git 版本原因git clone 无法输入密码问题

git出现error: The requested URL returned error: 401 Unauthorized while accessing得到原因是因为服务器的git版本是 git version 1.7.1

  • 可以使用如下操作:
git clone https://username:password@url/project.git

如果这样设置,下次密码变更时,需要重定向git仓库地址:

git remote set-url origin url  #同样需要再url中定义账号和密码

4. 其他:清除记住的用户、密码

git config --system --unset credential.helper

转载于:https://www.cnblogs.com/doraman/p/11388068.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值