今天在提交github代码的时候出现了下面的错误:

[remote rejected]   ben1 -> ben1 (permission denied)

我猜想是因为没有输入用户名和密码的缘故。

解决方法

git config --global --edit

添加如下内容:

[credential]
  helper = osxkeychain
  useHttpPath = true

重新push的时候,会提示输入用户名和密码,我输入用户名和github产生的token就行了。

参考文献

macOS下git push报错! [remote rejected] main -> main (permission denied)