Mac 终端设置或清除 Git 账号和密码

3,107 阅读1分钟

参考-Mac 终端设置或清除 Git 账号和密码

在sourceTree克隆 基本保存钥匙串哦

image.png

本地克隆的话 也是钥匙串

image.png

删除用户密码

也可能出现在修改密码情况,也需要先删除

Git 用户名和密码的存储是通过 credential helper(凭证) 实现的

  • 缓存中找
  • 磁盘中找
  • 钥匙串中找

查看 credential

git help -a | grep credential

image.png

查看全局配置

git config --list

image.png

credential.helper=store 这是存store

打开gitconfig文件

image.png

cat ~/.gitconfig
vi ~/.gitconfig

image.png

钥匙串 删除

image.png

image.png

gitclone 就提示输入密码了

image.png

保存

保存磁盘

git config --global credential.helper store

保存钥匙串

git config --global credential.helper osxkeychain

如果设置了 osxkeychain 后发现执行 Git 命令依然报 403 的错误,很有可能是原来的钥匙串没有被删掉,务必检查一下钥匙串中老的密码是否删除了