I have a dotfiles repository for macOS which contains the .gitconfig
file. I would like to keep username
and email
separate from this file so that these variables are never committed as part of my public dotfiles repository.
One approach I have seen is to specify a file called .extra
, keeping it in the ~/
directory (it is referenced it in .bash_profile
) and set the Git variables in that file, so that they are external to my public repository, i.e. any public changes I make to .gitconfig
will not include the username
and email
.
The problem is none of the approaches to setting these values are working for me. Following every attempt I get the following message:
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
I have the following in my .extra
file, and his failed to work:
GIT_AUTHOR_NAME="First Last"
GIT_COMMITTER_NAME="First Last"
I have tried various approaches using these variables and others, as well as including and excluding quotation marks, and even prefixing these lines with export
. At a bit of a loss!