git:不允许使用空标识名称(用于 <>)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41832926/
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
git : empty ident name (for <>) not allowed
提问by Rohan Kumar
I was applying a diff fileof an opensource project on the top of my repository using git-am :
我正在使用 git-am 在我的存储库顶部应用一个开源项目的diff 文件:
git am -3 < /Downloads/refactorWork.diff
but it had conflicts and i had to resolve them; but after resolving the conflicts and staging them, when i did git am --continue i got :
但它有冲突,我必须解决它们;但是在解决冲突并暂存它们之后,当我执行 git am --continue 时,我得到了:
fatal : empty ident name (for <>) not allowed
I looked up on the internet and found thiswhich seemed to be similar to my problem but my usename and email were already added up in global and local git directories. Here is the output of git config list :
我在互联网上查了一下,发现这似乎与我的问题相似,但我的用户名和电子邮件已经添加到全局和本地 git 目录中。这是 git config list 的输出:
rohan@~/Documents/libo : $ git config --global --list
[email protected]
user.name=Rohan Kumar
alias.l=log --oneline --graph --pretty
credential.helper=cache
Although i solved this by first commiting the staged changes and then using git am --skip
, I am interested in knowing what does that error means and whether what i did was the correct way of doing it, or is there any better way?
尽管我通过首先提交分阶段更改然后使用 解决了这个问题git am --skip
,但我很想知道该错误意味着什么以及我所做的是否是正确的做法,还是有更好的方法?
采纳答案by Vampire
This diff file is a plain diff, not something generated by git format-patch
. A format-patch
generated diff contains information about the commit author, author date, commit message, ... and maintains this information when creating the commit(s).
这个 diff 文件是一个普通的 diff,不是由git format-patch
. 一个format-patch
产生差异包含有关提交作者,作者日期,提交信息,...以及创建提交(S)时保留此信息。
Your plain diff does not have these information, so git am
will complain that it is missing naturally.
您的普通差异没有这些信息,因此git am
会抱怨它自然丢失。
You should instead have used git apply
which is meant to apply simple patch files like you have in this case which will only apply the patch to the worktree (and index if you tell it to) but does not create any commit automatically.
您应该使用git apply
which 来应用简单的补丁文件,就像在这种情况下一样,它只会将补丁应用到工作树(如果您告诉它,还有索引),但不会自动创建任何提交。
回答by Savindya A
Use,
用,
git apply -3 patchName.patch
git apply -3 patchName.patch
when you encounter conflicts, open your mergtool and resolve conflicts
当你遇到冲突时,打开你的 mergtool 并解决冲突
git mergetool
git合并工具
that's all :)
就这样 :)
回答by izogfif
Moved out of comment to the accepted answer
移出对已接受答案的评论
When you click "Save unified diff" in TortoiseGit, you must right-click the created .diff
or .patch
file and select TortiseGit→Review/apply single patch
instead of Apply Patch Serial...
.
当您在 TortoiseGit 中单击“保存统一差异”时,您必须右键单击创建的.diff
或.patch
文件并选择TortiseGit→Review/apply single patch
而不是Apply Patch Serial...
.
Put the diff file in the root of the folder to which files you want to apply the patch to, first.
首先将 diff 文件放在要应用补丁的文件夹的根目录中。