问题原因:
账号密码验证不通过,密码或者权限不对,导致 Git 操作失败

解法一:删除 credential.helper

  1. git config --system --unset credential.helper

然后输入Git远程服务器的新密码。
然后还是不行:

  1. git config --system --unset credential.helper

然后输入Git远程服务器的新密码。

解法二:Mac 配置ssh

  1. cd ~/.ssh
  2. ls -a //查看是否已经存在

如果没有生成新的ssh key

  1. ssh-keygen -t rsa -C "email@.com"

将id_rsa.pub中的内容复制,然后在GitHub或者Gitlab点击add ssh key
image.png

在 git push 代码时报remote: HTTP Basic: Access denied

  1. git config --global credential.helper osxkeychain

之后再操作git push 或者 git pull 输入正确的用户名与密码

如果还是不行

解法三:删除mac 钥匙串

Delete the password in keychain access.
image.png

  • cmd+space and type “KeyChain Access”,
  • You should find a key with the name like “gitlab.*.com Access Key for user”. You can order by date modified to find it more easily.
  • Right click and delete.