git用户信息和免密配置

2021-02-13  本文已影响0人  Jerry_1116

git管理的代码仓库,在pull和push代码的过程中,需要进行身份校验。为了避免每次pull和push代码都需要输入用户名、密码等信息,可以进行配置用户名、邮箱和密码保存等信息。
以下操作以Ubuntu20.04.2操作系统为例:

$ git config --global user.name {yourname}
$ git config --global user.email {youremail}
$ git config --global credential.helper store    # 永久保存密码 

以上配置完成之后,下次进行pull或push的时候,只需要输入一次用户名和密码,就可以自动保存,之后的操作都不需要输入用户名和密码。
当然,这样做也存在一定的安全隐患。git还支持更加灵活的配置,例如密码缓存一段时间。

$ git config --global credential.helper cache      # 临时缓存密码,默认15分钟
$ git config --global credential.helper 'cache --timeout=3600'      # 临时缓存密码,3600s,也就是1小时

参考

  1. git credential cache
  2. git credentials
上一篇 下一篇

猜你喜欢

热点阅读