我已从~/.gitconfig
删除了我的凭据,但是当我运行git commit -m "some crap"
时,它仍以我的名字提交。
如何阻止它提交?我需要在我的程序中测试一些需要git commit
命令失败的功能。
答案 0 :(得分:4)
Git
会从多个地方收集作者的电子邮件,如果它在任何这些地方都找不到,那么它会自行创建。见man git-config
:
user.email
Your email address to be recorded in any newly created commits. Can be overridden by the GIT_AUTHOR_EMAIL,
GIT_COMMITTER_EMAIL, and EMAIL environment variables. See git-commit-tree(1).
因此,如上述评论中所述,首先检查您是否在.git/config
中配置了电子邮件,然后检查联机帮助页中列出的所有变量。由于缺少电子邮件导致git commit
失败很难,因为即使它没有明确设置它也可以提交,至少在{{1}上}:
Linux
编辑:话虽如此,我更喜欢使用$ touch 1243
$ git add 1243
$ git commit -mm
[email-test eab3127] m
Committer: Arkadiusz Drabczyk <ja@comp.a>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:
git config --global user.name "Your Name"
git config --global user.email you@example.com
After doing this, you may fix the identity used for this commit with:
git commit --amend --reset-author
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 1243
$ echo $?
0
变量设置我的电子邮件,因为其他程序也可以理解作为EMAIL
或doxygen
,而不仅仅是mutt
。