Git multiple user names for the different projects within the same system


I have a different git repository for my office and a different git repo for my hobby projects.

When I do git config --global
the user name changes globally and this creates a confusion
of committing to a repo with user name.

Hence the question is how can i have the same username across all my hobby projects and
the same username across the office projects. I use the same machine to work on both the places.

Best Solution

Just use --local instead of --global. In fact, local is the default so you can just do

git config
git config "whatf hobbyist"

in one repo, and

git config
git config "whatf at work"

in another repo

The values will then be stored in in the .git/config for that repo rather than your global configuration file.