Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I specify multiple users for myself in .gitconfig?

Tags:

git

git-config

In my ~/.gitconfig, I list my personal email address under [user], since that's what I want to use for Github repos.

But, I've recently started using git for work, too. My company's git repo allows me to commit, but when it sends out announcements of new changesets, it says they are from Anonymous because it doesn't recognize the email address in my .gitconfig - at least, that's my theory.

Is it possible to specify multiple [user] definitions in .gitconfig? Or is there some other way to override the default .gitconfig for a certain directory? In my case, I check out all work code in ~/worksrc/ - is there a way to specify a .gitconfig for only that directory (and its subdirectories)?

like image 900
Brock Boland Avatar asked Nov 18 '10 22:11

Brock Boland


People also ask

Can two people use the same Github account?

You can either use the same key on both or add multiple keys to your github account. If you attempt to use the same account for multiple people though it might get messy if you don't have a solid workflow.


1 Answers

You can configure an individual repo to use a specific user / email address which overrides the global configuration. From the root of the repo, run

git config user.name "Your Name Here" git config user.email [email protected] 

whereas the default user / email is configured in your ~/.gitconfig

git config --global user.name "Your Name Here" git config --global user.email [email protected] 
like image 134
discomurray Avatar answered Nov 03 '22 00:11

discomurray