git push的时候每次都要输入用户名和密码的问题解决

本文介绍了如何将Git远程仓库的验证方式从HTTPS更改为SSH,以避免每次推送代码时都需要输入用户名和密码的情况。通过具体步骤展示了如何移除原有远程仓库配置并重新添加SSH方式的远程仓库。
  • 换了个ssh key,发现每次git push origin master的时候都要输入用户名和密码
  • 原因是在添加远程库的时候使用了https的方式。。所以每次都要用https的方式push到远程库
  • 查看使用的传输协议:
git remote -v
wuxiao@wuxiao-C-B150M-K-Pro:~/MyGithub/DailyBlog$ git remote -v
origin https://github.com/toyijiu/DailyBlog.git (fetch)
origin https://github.com/toyijiu/DailyBlog.git (push)
  • 重新设置成ssh的方式:
git remote rm origin
git remote add origin git@github.com:username/repository.git
git push -u origin master
  • 再看下当前的传输协议:
    wuxiao@wuxiao-C-B150M-K-Pro:~/MyGithub/DailyBlog$ git remote -v
    origin git@github.com:toyijiu/DailyBlog.git (fetch)
    origin git@github.com:toyijiu/DailyBlog.git (push)

     

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值