12/28/2021 Note: corrected code block format
I’m using multiple git repositories for various work related and personal related projects.
Recently I was working with a repository at work and notice my personal email address in the commit log. Well, this wasn’t cool. I mean my personal email is awesome, but having it appear in work related commit log was… well not cool.
.gitconfig had the following parameters set correctly for my personal Git repositories.
[user] name = Boogy Man email = email@example.com
git config --list can be used to view a list of defined values for a Git config. Run this command from anywhere within the system.
If your command prompt resides in a cloned git repository, the command output from
git config --list will include the output from the
.gitconfig plus any local values in the
.git/config file of that cloned repository.
Also, using anyone of the
more or favorite editor will achieve the same result.
.gitconfig is the global config that resides outside of any repositories. Each git repository has it’s own
config file within it.
email = firstname.lastname@example.org stanza in the
.gitconfig will influence Git to prompt for a name and email on a per repository basis. This of course will occur one time that repository and there after the user name and email will be recored within the repository’s
first step: Updating the global git config first 3,
shell$ cd ~ shell$ git config --global user.useConfigOnly true shell$ git config --global --unset-all user.email
second step: Then moving into the work repository the following is performed to set the work related email ,
shell$ cd /some_dir/git_clone_dir shell$ git config user.email "email@example.com" shell$ git config --list
The same will be done on any other local repository.
note: If just updating the git global
.gitconfig is all you do, and skip setting the then the following git message will appear when you run
git commit *** Please tell me who you are. Run git config --global user.email "firstname.lastname@example.org" git config --global user.name "Your Name" to set your account's default identity. Omit --global to set the identity only in this repository. fatal: no email was given and auto-detection is disabled
- https://orrsella.com/2013/08/10/git-using-different-user-emails-for-different-repositories/ ↩
- https://github.com/git/git/commit/c37f9a1bc38cad56c9eca40014802e7cd822c21c ↩
- The global config will display the
user.emailfrom the global
.gitconfigin the output from
git config --list. This is why we want to first remove the
user.emailfrom the global