2016-01-13 25 views
1

我从~/.gitconfig删除我的凭据,但是当我运行git commit -m "some crap"它仍然有我名字的承诺。我删除了我的电子邮件和尼克gitconfig,但它仍然能够提交

我怎样才能阻止它能够承诺?我需要在我的程序中测试一些功能,它需要git commit命令失败。

+0

也许它的凭证范围不是项目全球。检查你的项目的.gitconfig或运行'git config user.name“你的名字”'。这将覆盖您的项目特定配置。 – Ramin

+0

检查'git的/ config' – 2016-01-13 19:07:18

回答

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失败,因为即使它没有明确设定有可能做出承诺,至少在Linux

$ touch 1243 
$ git add 1243 
$ git commit -mm 
[email-test eab3127] m 
Committer: Arkadiusz Drabczyk <[email protected]> 
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 [email protected] 

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变量,因为它也是由其他程序,如doxygenmutt不仅git理解为设置我的电子邮件。

+0

@Arkdaiusz,谢谢您的回答。这个交易是我需要用我们的软件测试报告的错误,用户说如果我们设置这样的凭证,那么'git config --global user.name''''在提交时软件将失败。那么,你说这是不可能的?此外,我只能使用普通的'git commit'命令,但我可以删除并删除任何导致错误的凭据。我会问他提供更多信息。 – pushandpop

相关问题