By default, git
uses the /<Users>/.gitconfig
file to obtain information related to a user during a commit.
This can be a big problem when working on multiple projects spread across different clients or when having separate accounts for work and personal git accounts.
To resolve this issue, the following possible solution can be used.
- Open a console or terminal.
- Change the working directory to the repository that needs to have the user and email configured.
- Run the below command to change
user.name
:
git config user.name "<enter-user-name-here>"
- Run the below command to change
user.email
:
git config user.email "<enter-user-email-here>"
Repeat the above steps to change the user.name
and user.email
for each git
repository that needs to be configured.
Summary
By using the git
command line, it is very easy to change the user.name
and user.email
properties per repository. Simply navigate to the repository using a console or terminal and enter the following commands:
git config user.name "<enter-user-name-here>"
git config user.email "<enter-user-email-here>"
Software versions used in this article
- git v2.26.2.windows.1