使用SSH提交Git时要求输入电子邮件地址

3

我试图提交到我的Github仓库,但是我一直收到一个错误消息,要求我通过电子邮件和姓名登录来确认身份。我正在使用ssh进行提交,我的ssh配置和密钥已经正确配置。我还检查了gitconfig文件,它们似乎也是正确的。有什么想法吗?

最初的回答:

您需要在本地计算机上设置Git用户信息。请尝试在终端中运行以下命令:

git config --global user.email "your_email@example.com"

git config --global user.name "Your Name"

###Gitconfig file
[core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true
[remote "origin"]
    url = git@github.com:imran1005/testhomere.git
    fetch = +refs/heads/*:ref
[branch "master"]
    remote = origin
    merge = refs/heads/master

###Error msg on console win7 cmd while executing git commit:

*** 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: unable to auto-detect email address (got 'TestUser@Asus.(none)')

git config --global user.email你会得到什么输出? - Muhammad Saqlain
我得到了一个空的输出 - Lee Wyi
3
按照错误提示中的指示操作。除了已经登录Github账户外,你的git提交应该表明你的身份信息。因此,请在以git config开头的两行中填写你的个人信息。 - ferrix
1
这意味着你的凭证在git配置中没有设置。你需要为你的git配置设置电子邮件、姓名和密码。 - Muhammad Saqlain
我正在使用SSH,使用RSA密钥进行身份验证。在使用SSH提交时,我不需要设置电子邮件名称和密码。 - Lee Wyi
git remote -v验证您的URL是否设置为SSH。 - Muhammad Saqlain
1个回答

3
作为错误信息所述,您需要设置user.emailuser.name git配置。这些信息存储在提交中,没有它们,git将无法工作。

我的sshconfig和密钥已经正确配置了。

这与此无关,当您推送现有提交到某个远程时才会使用ssh密钥,而不是在创建新提交时。

1
谢谢。确实,你说得对,即使使用SSH提交,也应该配置电子邮件! - Lee Wyi

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接