How to change your git username or email on a per repository basis

If you use dif­fer­ent set­tings while com­mit­ting to your repos­i­to­ries such as a dif­fer­ent user­name for work and home, you might want to setup your user­name and email on a per repos­i­tory basis. You can eas­ily do that by run­ning the fol­low­ing com­mands from your project’s root directory

git config user.name <USERNAME>
git config user.email <EMAIL>

To check if the changes are suc­cess­ful, you can run

git config user.name
git config user.email

If you want to see all of the set­tings applied — a com­bi­na­tion of global and repos­i­tory level, you can run

git config --list

If you want to see the set­tings that are only spe­cific to your repos­i­tory, i.e. the ones that are over­rid­ing the global set­tings, just open the .git/config file

cat .git/config

Ryan Sukale

Ryan is just a regular guy next door trying to manage his life and finances.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *