Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable Git auto-detecting email address?

Tags:

git

On my desktop, if I don't explicitly set the user and email for a repository, git will throw an error saying it was unable to auto-detect my email address and will stop my commit. Given I work on a number of different repositories and want different author/email settings for each, I quite like this functionality.

I know this happens because my user/email is not configured. I am not asking how to resolve this error. Instead, I would like to know if it is possible, and if so how, to configure git to never auto-detect my email address?

On my laptop it does auto-detect. I then configure my user/email but then have to amend my commit. I would like it to reject my commit if I have not configured my user/email.

like image 299
Shaun Hamman Avatar asked Oct 23 '25 09:10

Shaun Hamman


1 Answers

Set user.useConfigOnly to true. (Assuming git >=2.8)

This will make git error out if no name or email are configured.

git config --global user.useConfigOnly true
like image 72
Hasturkun Avatar answered Oct 26 '25 23:10

Hasturkun



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!