Git安装后 设置邮箱,生成SSH key,切换远端协议http ssh

一、设置user.name 和 user.email

  1.查看user.name和user.email

    git config --list     //查看配置

    git config user.name

    git config user.email

  2.配置user.name  和 user.email(global为全局配置)

    git config --global user.name  "myname"

    git config --global user.email  "[email protected]"

二、设置SSH Key

  1.查看本地是否已经有ssh文件(pub文件)

    我的文档   --->  .ssh目录下。id_rsa、id_rsa.pub文件

  2.生成ssh key

     ssh-keygen -t rsa -C "[email protected]"

  3.添加到Github ssh配置中。
三、切换https和ssh协议(.git 下config文件)

  1. 查看当前remote

    git remote -v

  2. 切换到https:

    git remote set-url https://github.com/yourusername/repository.git

  3. 切换到ssh:

    git remote set-url [email protected]:yourusername/repository.git

四、https协议,密码缓存。(我的文档下.gitconfig文件)公司vpn连接时,只能用https协议。

  git config --global credential.helper store

 
 

  

  

猜你喜欢

转载自www.cnblogs.com/dalaogan/p/10807770.html