0 votes
1 view
in DevOps and Agile by (19.4k points)

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)?

1 Answer

0 votes
by (27.5k points)

One way is to configure an individual repository to use a specific user or email address which overrides the global configuration as shown below:

Run this command from the root of the repository:

$ git config user.name "Add User Name Here"

$ git config user.email [email protected]

Note that the default user information is configured in your ~/.gitconfig

$ git config --global user.name "Add User Name Here"

$ git config --global user.email [email protected]

Welcome to Intellipaat Community. Get your technical queries answered by top developers !