How to enable multiple usernames for git? ie. Specific project can have specific username

4.4k Views Asked by At

I am working with 2 projects in same time. One is for my work and another is my personal project. I'd like to use git as version control software.

I have configured .gitconfig under my my directory as follows.

  1 [user]
  2   name = gladder
  3   email = gladder

So git can pickup my user settings automatically. however, I am just wondering that is it possible to get this setting in small scope?

So the project's user settings can override global user settings.

2

There are 2 best solutions below

0
On

Yes, all the settings that are in $HOME/.gitconfig can be put into .git/config inside each repository.

2
On

You can use the --file flag with git config (or not as it is the default):

git config --file user.name gladder
git config --file user.email gladder

which will create/set the value in project/.git/config (as araqnid said)

Refer to git-config for more information.