ubuntu使用git提交github时,执行pull或者push命令要重新输入用户名和密码

ubuntu使用git提交github时,执行pull或者push命令要重新输入用户名和密码:

1:问题现象:

hlp@hlp:~/code/github_code/catch_imooc1$ git push
Username for 'https://github.com': XXXX
Password for 'https://XXXX@github.com': 
Counting objects: 20, done.

 2:问题原因:

使用git clone 克隆代码的时候默认使用了https的方式而不是ssh的方式。

本地查看方式:
hlp@hlp:~/code/github_code/catch_imooc1$ git remote -v
origin	https://github.com/XXXX/xxx.git (fetch)
origin	https://github.com/XXXX/xxx.git (push)

 3:修改方案:

修改git clone 克隆代码方式为ssh的方式:

       1:获取ssh代码库地址,在github项目主页中,修改https地址方式为ssh方式

              

  2:移除本地https获取方式,切换成ssh方式:

修改https获取方式为ssh方式:
hlp@hlp:~/code/github_code/catch_imooc1$ git remote rm origin

查看本地代码库获取方式:
hlp@hlp:~/code/github_code/catch_imooc1$ git remote -v

修改本地代码库git获取地址为ssh方式:
hlp@hlp:~/code/github_code/catch_imooc1$ git remote add origin git@github.com:XXXX/xxxx.git

查看本地代码库获取方式:
hlp@hlp:~/code/github_code/catch_imooc1$ git remote -v
origin    git@github.com:XXXX/xxxx.git (fetch)
origin    git@github.com:XXXX/xxxx.git (push)

测试验证:
hlp@hlp:~/code/github_code/catch_imooc1$ git push origin master
Warning: Permanently added the RSA host key for IP address '13.250.177.223' to the list of known hosts.
Everything up-to-date

4:参考博文:

 https://www.cnblogs.com/sky6862/p/7992736.html

5:声明:

    该博文只是为了规范自己的习惯,如有问题或者建议,请谅解。

 

转载于:https://www.cnblogs.com/yun6853992/p/9348484.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值