GIT 密码/凭证管理

设置记住密码:

# 默认缓存(默认15分钟)
git config --global credential.helper cache
# 指定缓存时长
git config credential.helper 'cache --timeout=3600'
# 长期存储密码
git config --global credential.helper store

增加远程地址的时候带上密码也是可以的(不建议)

# 进入仓库所在目录
cd projectfolder/
# 移除远程ssh方式的仓库地址
git remote rm origin
# 增加https远程仓库地址
git remote add origin http://yourname:password@git.oschina.net/name/project.git

http(s)->ssh

# 生成密钥对
ssh-keygen -t RSA -C email@email.com
# 添加 id_rea.pub 到仓库

# 如果本地仓库是使用的 http(s) 的需要执行如下操作,如果本身就是 ssh 克隆的,请忽略
git remote rm origin
git remote add origin git@gitee.com:{your path}/{project name}.git

重置凭证

当密码修改或重置后,也需要同步修改 credential 中的密码,可以使用如下命令,重置 credential 存储的密码

# 重置所有密码。也可以通过参数重置指定范围内的密码。具体请参照 git credential --help
git credential reject

# 或者
git config --global --unset credential.helper
git config --system --unset credential.helper
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值