git pull和push老是提示输入Git账号密码的解决方法

最近的项目在执行 git pull/push 的时候,老是提示要输入账号和密码。输入正确之后,下次执行 git pull/push 的时候还需要重新输入账号密码。

这应该是我不知道啥时候使用了错误的账号和密码,解决方法很简单:先 cd 到根目录,执行以下命令:

git config --global credential.helper store

执行之后会在 .gitconfig 文件中多出一项 【credential】:

[user]
        name = Deshun
        email = admin@w3h5.com
[credential]
        helper = store

然后 cd 到项目目录,执行 git pull 命令,会提示输入账号密码。

输完这一次以后就不再需要,并且会在根目录生成一个 .git-credentials 文件

git pull
Username for 'https://github.com': xxxx@xxxx.com
Password for 'https://admin@w3h5.com@github.com':
cat .git-credentials
https://Username:Password@github.com

之后 pull/push 代码都不再需要输入账号密码了。


未经允许不得转载:Web前端开发资源网 » git pull和push老是提示输入Git账号密码的解决方法

推荐阅读:

PHPStorm 如何更改文件的打开方式

用css实现文本溢出 超出部分隐藏显示省略号

Ueditor后端配置项没有正常加载,上传插件不能正常使用!的解决过程。

给网站添加熊掌号粉丝关注按钮

20180410博客更换服务器步骤

赞 (0)
分享到: +

评论 沙发

Avatar

换个身份

  • 昵称 (必填)
  • 邮箱 (选填)