Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git 未被承认的作者_Git_Github - Fatal编程技术网

Git 未被承认的作者

Git 未被承认的作者,git,github,Git,Github,当我在计算机上从Git Bash提交文件并将其推送到GitHub上时,我不会被识别为提交的作者: 当指向问号时,将显示以下消息: 未被承认的作者。如果是您,请确保您用于提交的电子邮件地址与您的帐户关联。您可以在“设置”中将电子邮件添加到您的帐户 问题是我检查了好几次,我可以向您保证这两个电子邮件地址是对应的 git config--全局user.email 显示与中给出的电子邮件地址完全相同的电子邮件地址 我使用Windows 7并使用SSH连接到远程存储库。使用git show或git sh

当我在计算机上从Git Bash提交文件并将其推送到GitHub上时,我不会被识别为提交的作者:

当指向问号时,将显示以下消息:

未被承认的作者。如果是您,请确保您用于提交的电子邮件地址与您的帐户关联。您可以在“设置”中将电子邮件添加到您的帐户

问题是我检查了好几次,我可以向您保证这两个电子邮件地址是对应的

git config--全局user.email

显示与中给出的电子邮件地址完全相同的电子邮件地址


我使用Windows 7并使用SSH连接到远程存储库。

使用
git show
git show
检查提交的作者电子邮件是否正确。如果没有,请使用git config user.email“”,因为您可能已经更改了该特定回购协议的设置,而不考虑您的全局配置。

好的,我找到了解决方案

基本上,
git config--global user.email
包含了好的电子邮件地址,但是
git config user.email
没有


所以我只需要修改本地的一个,它就工作了。但仍不知道原因。

要为您的未来提交设置正确的名称和电子邮件:

git config --global user.name "John Doe"
git config --global user.email johndoe@example.com

如果希望修复以前未完成的提交,请按照以下步骤操作:

  • 请务必
    git show
    并记住所使用的电子邮件:

    $ git show
    commit ca44c93b9433346f858676a8f1b83f3d9757ec65
    Author: John Doe <johndoe@johndoes-MacBook-Pro.local>
    
  • 旧电子邮件
    更正名称
    更正电子邮件
    ,然后将
    光盘
    粘贴到存储库并粘贴脚本。按回车键

    #!/bin/sh
    
    git filter-branch --env-filter '
    
    OLD_EMAIL="your-old-email@example.com"
    CORRECT_NAME="Your Correct Name"
    CORRECT_EMAIL="your-correct-email@example.com"
    
    if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
    then
        export GIT_COMMITTER_NAME="$CORRECT_NAME"
        export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
    fi
    if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
    then
        export GIT_AUTHOR_NAME="$CORRECT_NAME"
        export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
    fi
    ' --tag-name-filter cat -- --branches --tags
    
  • 强制推送至Github:

    git push --force --tags origin 'refs/heads/*'
    

  • 谢谢,
    git show
    没有显示正确的电子邮件地址,我使用了您的命令来更改它。它是有效的。在提交之前,您可能已经在该repo上运行了
    git config user.email
    。或者在提交后运行
    git config--global user.email
    。感谢您提供的解决方案,为我工作,并使我的GitHub统计数据恢复正常。将此作为推荐答案。
    git push --force --tags origin 'refs/heads/*'