category
type
status
date
slug
summary
tags
password
Property
Feb 28, 2023 05:34 AM
icon

前言

最近同时在Windows CMD和WSL terminal下使用git进行代码的clone和push时发现了如下问题: 1.在Windows下使用git clone https://xxx 方式clone 代码后会弹出一个身份验证框用于登录验证,身份验证成功后,在该台PC上进行的任何git 的clone和push操作都无需二次验证。 2. 而在WSL下使用https模式clone代码则后续每次对对应代码仓库的push操作都需要重新输入username和password进行身份验证,而且password还是比较敏感的AccessToken。

git clone下的https和ssh模式的区别

https

  • git clone https://xxxx
  • 该种方式在像WSL类似的纯终端系统上使用非常不友好,使用该种方式clone的仓库每次push时都需要重新验证身份。

ssh

  • git clone git@github.com:xxxx
  • 该种方式下,只要在Github中设置好了对应主机使用的ssh key就可以验证主机的身份,所以每次push时都无需像https模式方式下重新输入username和password验证身份,非常方便。
  • 所以一般推荐尽量使用ssh模式clone代码

将https clone的仓库改为ssh模式

  • 进入仓库的.git 目录,按照如下方式修改config配置文件即可
notion image
notion image
Golang异常处理利用Kafka实现IM系统的写扩散模型
  • Twikoo
  • Giscus