git pull/push 每次都要输入用户名密码

604 阅读1分钟

执行 git config --global credential.helper store,输入用户名密码

cat ~/.gitconfig查看文件

[credential]
        helper = store

cat C:\Users\aoyu.git-credentials查看用户账号,格式为:http://{用户名}:{密码}@{git 网址}

http://1e.aaa%test.com:12345@git.test.com

折腾好几遍还是要输入密码,哭了。
后来发现是因为使用 http 的方式拉取代码才出现这个问题。
解决办法:切换 git 的拉取方式,将 http 改为 ssh 的方式。

git remote -v                           查看clone地址
git remote rm origin                    移除http地址
git remote add origin git@.......git    换成ssh方式

git remote -v 再次查看会发现成功的从 http 拉取方式切换为 ssh 拉取方式了。

完活!开心