Git 无法使用 SSH 连接

Git cannot connect with SSH

我注意到 Git 中不时随机出现的奇怪行为,因此我成功配置了我的 SSH 密钥,无需任何登录名或密码即可连接到 Bitbucket 存储库,因此我可以提取我的存储库 我进行了更改当我想再次提交时,会显示这个

*** 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 <Username@Your-PC.(none)>) not allowed

这太奇怪了,如果 SSH 密钥出了问题,那么我该如何拉取我的存储库,而且除了提交之外一切正常

Git 不使用任何类型的用户名密码组合。
它确实需要设置用户名和电子邮件,因为此信息是提交 blob 的一部分。

用户名和电子邮件是最少的,也是唯一需要您设置的信息git。

当使用中央存储库时,此类存储库的管理员可以决定他支持哪个 Transfer protocols 以及服务器是否支持 ssh 你需要使用 ssh 密钥,对于 https 你需要使用 user/password组合来验证你自己。

在您的情况下,您只需设置用户名和电子邮件以用于 git 提交。


回到你原来的评论:

This is so weird if something is wrong with SSH keys then how I can pull my repository, and also everything works fine apart from commiting

希望您现在明白为什么需要这些信息。
您可以在上图中看到提交需要什么。

发生此错误是因为电子邮件的格式不正确:

错误 ==>> 用户名@Your-PC.(none)>) 它没有 .com 或 .net

如果您使用的是像 Linux 这样的服务器,请确保主机名的域格式像 mydomain.com 或 myhostname.net