Git中ssh和http提交方式

一、SSH提交方式
  • 进入C盘用户目录,删除.ssh目录
  • 运行命令生成.ssh 密钥目录:ssh-keygen -t rsa -C 邮箱
  • 进入.ssh 目录查看文件列表,查看id_rsa.pub文件内容
  • 登录GitHub,点击用户头像→Settings→SSH and GPG
    keys
  • New SSH Key
  • 输入复制的密钥信息
  • 回到Git bash 创建远程地址别名
    git remote add origin_ssh git@github.com:atguigu2018ybuq/huashan.git
  • 通过配置了ssh,在进行push或者pull操作时,就不需要再次输入密码。在这里插入图片描述

在这里插入图片描述

二、Http提交方式
  • 在进行http提交时,要输入用户名和密码,Windows版本的Git会默认使用Windows凭据来保存Git验证身份在这里插入图片描述
  • 也可以通过使用credential helper它帮我们存储了credential(凭证,里面包含了用户名和密码)
  • Git会优先采用第一种方式
  • Git包含了如下的两个helper
    • Cache: cache 将凭据在内存中进行短时间的缓存.
      git config credential.helper cache                  // 当前项目,暂时存储密码,默认15分钟
      git config credential.helper 'cache --timeout=3600' // 当前项目,暂时存储密码,自定义时间()
      git config credential.helper store                  // 当前项目,永久存储密码
      git config user.name XXXX                           // 当前项目,设置用户名
      git config user.email ***@***.com                   // 当前项目,设置用户邮箱
      
    • Store: store 将凭据保存在磁盘上
      git config --global credential.helper cache                  // 当前用户所有项目,暂时存储密码,默认15分钟
      git config --global credential.helper 'cache --timeout=3600' // 当前用户所有项目,暂时存储密码,自定义时间()
      git config --global credential.helper store                  // 当前用户所有项目,永久存储密码
      git config --global user.name XXXX                           // 当前用户所有项目,设置用户名
      git config --global user.email ***@***.com                   // 当前用户所有项目,设置用户邮箱
      
  • Windows用户可以在 C:\Users\用户名.gitconfig 文件和.git-credentials中
    在这里插入图片描述
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值