• 0

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

If you use different settings while committing to your repositories such as a different username for work and home, you might want to setup your username and email on a per repository basis. You can easily do that by running the following commands from your project's root directory

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

To check if the changes are successful, you can run

git config user.name
git config user.email

If you want to see all of the settings applied - a combination of global and repository level, you can run

git config --list

If you want to see the settings that are only specific to your repository, i.e. the ones that are overriding the global settings, just open the .git/config file

cat .git/config