37 lines
1,007 B
Markdown
37 lines
1,007 B
Markdown
---
|
|
title: "per company git config"
|
|
seo_description: "how to configure git to use different emails per company / folder"
|
|
date: 2022-06-03T10:49:40+02:00
|
|
draft: false
|
|
snippet_types:
|
|
- git
|
|
---
|
|
|
|
Started new job this week and I wanted to have a seprate email on my work related repos then my
|
|
personal ones. Cool thing is git supports
|
|
[conditional config file includes](https://git-scm.com/docs/git-config#_conditional_includes)!
|
|
|
|
|
|
**~/.gitconfig**
|
|
```gitconfig
|
|
# per-user git config
|
|
[user]
|
|
name = Travis Shears
|
|
email = t@travisshears.com
|
|
|
|
[includeIf "gitdir:~/company-x/"]
|
|
path = .gitconfig-company-x
|
|
```
|
|
|
|
**~/.gitconfig-company-x**
|
|
```gitconfig
|
|
# Company X spefic git config
|
|
[user]
|
|
name = Travis Shears
|
|
email = travis.shears@company-x.com
|
|
```
|
|
|
|
Now any commits made under the directory **~/company-x** will use the email
|
|
**travis.shears@company-x.com** and not my personal email.
|
|
|
|
[source](https://stackoverflow.com/questions/8801729/is-it-possible-to-have-different-git-configuration-for-different-projects)
|