threads / discuss / 26238

different name and email address depending on folder

Subject: different name and email address depending on folder

## tl;dr

4 messages between Jan 8, 2011 and Jan 8, 2011.

replies: 3people: 2as markdown or json

Rich Eakin· Jan 8, 2011, 00:52 UTC · lore
Hi,
I am using git for development with a company and myself on the same computer and the name / user fields need to be different for each.  As I keep all my company's repos in one directory and my private stuff in another, I was wondering if there is a way to tell git to use a separate user and email whenever I make commits from within a specified directory.  
If anyone can tell me how to do this, or some other way to achieve my needs, I am very thankful.

Best Regards, Rich

Ramkumar Ramachandra· Jan 8, 2011, 07:39 UTC · re: Rich Eakin · lore

Re: different name and email address depending on folder

Hi Rich,
Rich Eakin writes:
> I am using git for development with a company and myself on the same computer and the name / user fields need to be different for each.  As I keep all my company's repos in one directory and my private stuff in another, I was wondering if there is a way to tell git to use a separate user and email whenever I make commits from within a specified directory.  

Yes. Please see the 'user.name' and 'user.email' configuration options in git-config(1). You can set them globally or on a per-repository basis.

-- Ram
Rich Eakin· Jan 8, 2011, 08:16 UTC · re: Ramkumar Ramachandra · lore

Re: different name and email address depending on folder

I am currently using git-config in a bash script to set my user / email.  I was wondering if it was possible to tell git that if I am in a certain directory to use a specific user / email other than what is in my global config.  
On 08/01/2011, at 6:39 PM, Ramkumar Ramachandra wrote:
Show 10 quoted lines
> Hi Rich,
> 
> Rich Eakin writes:
>> I am using git for development with a company and myself on the same computer and the name / user fields need to be different for each.  As I keep all my company's repos in one directory and my private stuff in another, I was wondering if there is a way to tell git to use a separate user and email whenever I make commits from within a specified directory.  
> 
> Yes. Please see the 'user.name' and 'user.email' configuration options
> in git-config(1). You can set them globally or on a per-repository
> basis.
> 
> -- Ram
Ramkumar Ramachandra· Jan 8, 2011, 08:29 UTC · re: Rich Eakin · lore

Re: different name and email address depending on folder

Hi Rich,
Rich Eakin writes:
> I am currently using git-config in a bash script to set my user / email.  I was wondering if it was possible to tell git that if I am in a certain directory to use a specific user / email other than what is in my global config.  

It's possible on a per-repository basis, as I pointed out in the last email; but no- I don't think it's possible on a per-directory basis within the same repository. You might consider separting your private work from your company's repository.

p.s- I think you've used the term "global" incorrectly here. Global configuration applies to all repositories. Per-repository configuration overrides the global configuration for that repository.

-- Ram

← back to recent threads