Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 405
Grace Ladder Avatar asked Jan 24 '11 00:01

Grace Ladder


2 Answers

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

like image 193
araqnid Avatar answered Nov 15 '22 20:11

araqnid


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.

like image 40
Antoine Pelisse Avatar answered Nov 15 '22 18:11

Antoine Pelisse