Search code examples
gitprivacyemail-address

Can I make git config not supply the value of my email?


If I run git config --get user.email, it displays my current email address. Is it possible to configure git such that I can set a value of the email for a commit, but it won't display it with the --get switch?

Alternatively, can I just set an environment variable such that git config --get user.email won't get anything, but my commits will still have my email? Or can my commits use a unique identifier other than my email address?

I had a brief look at the git-config documentation page, looking for mentions of --get and "email". The environment variables look promising but I haven't tried them.

Related question: Why does git ask for users' email address?


Solution

  • You cannot make git config unable to fetch the email that's used, because git config uses the same machinery as Git uses. However, you can avoid setting (or unset) user.email and use the environment variable EMAIL, which will set the value if user.email and the Git-specific environment variables are not set. I do this and it works great.

    The full details are in the git-commit manual page.