git pull 总要求输入账号和密码解决?

如果你用git从远程pull拉取代码,每次都要输入密码,那么执行下面命令即可

git config --global credential.helper store

这个命令则是在你的本地生成一个账号密码的本子似的东东,这样就不用每次都输入了(但是还得输入一次)

 

Git同步它人的远程仓库至自己的Git服务器 并自动定时更新
https://blog.csdn.net/qq_28387069/article/details/78757346

 

----------------

方法1:
使用HTTPS协议,有一种简单粗暴的方式是在远程地址中带上密码。
> git remote set-url origin http://yourname:password@bitbucket.org/yourname/project.git

还有一种方法,是创建文件存储Git用户名和密码。
以Windows环境为例,在%USERPROFILE%目录中(一般为C:\Users\yourname),打开Git Bash命令行,创建文件
> touch .git-credentials

在文件中输入仓库域名,这里使用了bitbucket.org。
https://yourname:password@bitbucket.org

方法2:
在CMD终端中设置在全局Git环境中,长期存储密码
> git config --global credential.helper store

其他设置密码方式
记住密码(默认15分钟):git config --global credential.helper cache
自定义存储时间:git config credential.helper 'cache --timeout=3600'
SSH协议推送
如果原来的推送地址协议是HTTPS,可以通过换成SSH协议,在远程仓库添加SSH Key来实现推送时免账户密码输入。
> git remote -v // 查看远程地址
> git remote rm origin // 删除原有的推送地址
> git remote add origin git@github.com:<用户名>/版本库名

或者
> git remote -v
> git remote set-url origin git@github.com:<用户名>/版本库名

执行推送。
> git push -u origin master

发现提示权限不够。
The authenticity of host 'bitbucket.org (104.192.143.1)' can't be established.
RSA key fingerprint is SHA256:zzXQOXSRBEiUtuE8AikJYKwbHaxvSc0ojez9YXaGp1A.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'bitbucket.org,104.192.143.1' (RSA) to the list of kn
own hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

需要在本地创建该帐号的RSA Key。可以参考以下两篇文章:
Windows下配置SSH连接Github
Git如何在本地生成多个SSH key
然后再执行推送。
> git push -u origin master

就可以推送成功了。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值