Git 设置配置用户名/邮箱,生成SSH key,切换远端协议https 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  "myemail@163.com"

二、设置SSH Key

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

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

  2.生成ssh key

     ssh-keygen -t rsa -C "myemail@163.com"

  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 git@github.com:yourusername/repository.git

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

  git config --global credential.helper store

五、git设置短命令

  git config --global alias.st status

  git config --global alias.co checkout
  git config --global alias.ci commit
  git config --global alias.br branch
  git config --global alias.ps push
  git config --global alias.pl pull

 
 

  

  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM