执行“git commit --amend”时出现“致命:不允许空身份名称”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43662048/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 04:57:08  来源:igfitidea点击:

Getting 'fatal: empty ident name not allowed' when doing 'git commit --amend'

git

提问by Di Zou

I am doing a git commit --amendand I get this error:

我正在做一个git commit --amend,我收到这个错误:

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

致命:不允许空标识名称(用于 <>)

I've found a bunch of stuff saying I need to set my user.emailand user.name, but I have. This is the the result when I do a git config --global --list:

我发现一堆东西说我需要设置我的user.emailuser.name,但我有。这是我做的结果git config --global --list

core.exludesfile=/home/dzou/.gitignore
core.editor=vim
[email protected]
user.name=dzou

core.exludesfile=/home/dzou/.gitignore
core.editor=vim
[email protected]
user.name=dzou

What is going on here? Thanks!

这里发生了什么?谢谢!

回答by dippas

Set global user.nameand user.emailfirst by order like below.

按如下顺序设置 globaluser.nameuser.emailfirst。

$ git config --global user.name "dzou"
$ git config --global user.email "[email protected]"

NB:careful, use double quote instead of single quotes

注意:小心,使用双引号而不是单引号

回答by G. Verni

I had a similar problem because when I committed, the user.emailwas set correctly but user.namewas empty. So even if I set the user name in the config, still I've got the same "empty ident" error.

我有一个类似的问题,因为当我提交时,user.email设置正确但user.name为空。因此,即使我在配置中设置了用户名,我仍然遇到相同的“空标识”错误。

I fixed it adding --reset-authorto the amend command (after setting the correct user.name)

我修复了它添加--reset-author到修改命令(设置正确后user.name

$ git commit --amend --reset-author

回答by emilyfy

I got the same problem after doing some filter-branch without using quotes too. That created a new user without any information hence the error, so the suggestion of configuring your own user name and email won't help.

在不使用引号的情况下做了一些过滤分支后,我遇到了同样的问题。这创建了一个没有任何信息的新用户,因此出现错误,因此配置您自己的用户名和电子邮件的建议无济于事。

I manged to fix it by editing the config file and removing the empty user. You can run

我设法通过编辑配置文件并删除空用户来修复它。你可以跑

$ git config --global -e  

and deleting the [user]line that doesn't have any member field. I had to do a reboot too but it works after that. Hope that helps!

并删除[user]没有任何成员字段的行。我也不得不重新启动,但在那之后它可以工作。希望有帮助!

回答by scilicet64

Fixed it by deleting localconfig and using the global configuration

通过删除本地配置并使用全局配置来修复它

$ git config --local -e

now delete all local lines and save the empty file

现在删除所有本地行并保存空文件

回答by Rautermann

A local setting can easily override the global settings! Just had this happen to me - while I did a really dirty fix using someone elses repo.

本地设置可以轻松覆盖全局设置!刚刚这件事发生在我身上 -而我使用别人的 repo 做了一个非常肮脏的修复

$ git config --local -e

$ git config --local -e

let's you remove or change the local values that disturb your commit!

让您删除或更改干扰您提交的本地值!

回答by Stiegi

I had the problem because I (ssh-)cloned the repo on another machine but with the same username and email. Ended up cloning it again, copied the new / changed files into the new clone and it worked. git config didn't help.

我遇到了问题,因为我 (ssh-) 在另一台机器上克隆了 repo,但使用相同的用户名和电子邮件。最终再次克隆它,将新的/更改的文件复制到新的克隆中并且它起作用了。git config 没有帮助。