我在不同的计算机上密集使用不同用户名的Git。有时候,当我克隆一个仓库,我忘记配置user.name
和user.email
,当我犯了第一个提交到本地仓库没有指定的标识名称,我得到如果未配置user.name和user.email,则在Git中中止提交
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
是的,这是完全清楚和为什么Git这样说。 (但是,如果我注意到它。)但是,是否可以抑制这种行为并使Git不会将我的用户名和主机名作为提交作者用户名传播?为什么我问的问题是,我的[user] name =
和[user] email =
都没有在我的~/.gitconfig
中:我只是针对不同的存储组使用不同的用户名和电子邮件,我希望Git只是在无法获得用户名时中止提交来自配置的电子邮件。最糟糕的是我有一个自定义的Git-informative PS1
配置显示当前的存储库用户名和电子邮件的权利,因为我有历史重写和强制推送几次,甚至没有注意到巨大的Git警告用户名默认。
如果全局未指定user.name
和user.email
,是否可以放弃Git中的提交? (我想它可以通过挂钩是固定的,但挂钩是本地唯一的,对吧?)
虽然我希望它是简单的。我感到羞愧,因为我无法看到这个选项,以及我无法有时阅读我的'PS1'......谢谢! –
有趣的细节:'user.useConfigOnly'似乎不起作用,如果'.gitconfig'中的'user ='和'email ='没有值(我的意思是'= \ n')并且没有被注释掉。 –