【问题标题】:"*** Please tell me who you are." when using SSH key“***请告诉我你是谁。”使用 SSH 密钥时
【发布时间】:2017-02-20 02:36:54
【问题描述】:

在我添加 ssh 密钥并检查它是否已成功验证后,我正在为 git 使用 ssh 密钥。但是我还是不能提交代码

$ eval "$(ssh-agent -s)"
Agent pid 2599

$ ssh-add ~/id_rsa
Identity added: /home/vagrant/id_rsa (/home/vagrant/id_rsa)

$ssh -T git@github.com
Hi my-git-username! You've successfully authenticated, but GitHub does not provide shell access. 

但我不能提交

$ git commit -m "Develop Dockerfile for shopContainer"

*** 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 'vagrant@vagrant-ubuntu-trusty-64.(none)')

【问题讨论】:

标签: git github


【解决方案1】:

运行
git config --global user.email "you@example.com"
git config --global user.name "你的名字"

注意:您已成功通过身份验证,但 git 需要您的 username & email 进行提交。

它与身份验证无关。您的 username/email 可以与您的 GitHub 帐户不同。

您需要运行以下命令一次

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

$ git config --list    # see if the 'name' & 'email' are set correctly

这个user.name & user.email 将在~/.gitconfig 文件中全局设置。

$ cat ~/.gitconfig     # see global config file

See more details

【讨论】:

  • 但是为什么这个信息会丢失,我需要一次又一次地输入呢?
  • 关于 cat ~/.gitconfig 的重点是关键......必须编辑该文件
【解决方案2】:

这个错误告诉你从命令中省略 --global 没有别的。 要摆脱此错误,请按照我的步骤操作...

只需将此命令放在你的 git 控制台中 ->

    $ git config user.email "Your@emailaddres.com"
    $ git config user.name "Your name"

在此之后,您的姓名和电子邮件将被设置为 git,您现在可以提交了。

    $ git commit -m "Msg you want to print during commit"  ##This will commit successfully##

输出->

    [master (root-commit) 7d5681a] done

    1 file changed, 1 insertion(+)

    create mode 100644 demo.txt

如果对你们有帮助,请告诉我。

【讨论】:

    【解决方案3】:

    其他答案的建议在 2020 年不再有效。要删除重复的条目,现在的方法是:

    git config --global --unset-all user.name
    git config --global --unset-all user.email
    

    您可能还必须在本地取消设置它们,即没有 --global 标志。然后按照其他答案中的指示再次设置它们,即:

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

    【讨论】:

    • 为我工作。谢谢。
    【解决方案4】:

    键入您在 GitHub 帐户中的相同名称。

    GitHub 账户名:

    git 用户名:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-24
      • 2016-04-03
      • 2015-12-17
      • 2014-09-14
      • 1970-01-01
      • 1970-01-01
      • 2019-01-03
      • 2013-05-29
      相关资源
      最近更新 更多