Git Commit 要求提供凭据而不是 WSL2 中的 SSH

Git Commit asks for credentials instead of SSH in WSL2

使用 SSH 密钥似乎一切正常,但当我这样做时:

git commit -m "message"

它给了我这个:

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: empty ident name (for <COMPUTER_NAME>) not allowed

就像我说的,其他一切,git 添加,git 推,git 拉都按预期工作(Git push/pull 要求 SSH 身份验证) 除了提交。

我检查了 .git/config 文件以确保它是为 SSH 设置的,事实上它是。

这不是凭据提示。当您进行提交时,Git 需要知道名称(即个人姓名,而不是用户名)和要嵌入到提交中的电子邮件地址。此数据与身份验证完全无关,只是 Git 创建提交所必需的。提交后,您可以使用 git log.

查看此数据

您应该按照指示指定您的个人姓名和电子邮件地址,然后提交才能成功。