Skip to content

Commit

Permalink
Merge pull request #45 from justinabrahms/corporate-vs-personal
Browse files Browse the repository at this point in the history
Document how to separate work vs personal personas in gitconfig.
  • Loading branch information
misappi authored Mar 16, 2022
2 parents c4f5e80 + 6dd144d commit 09a527d
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions content/05-appendix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Appendix
## Managing work vs personal emails in git
In the world of open source, folks may have an online identity that pre-dates
their employment with our current organization. Simultaneously, the organization
may want contributions done on their behalf to happen with corporate emails.

One way that folks can solve this is by encoding their commit email on a
per-repository basis, like:

```
git config user.email "[email protected]"
```


If you work with several repositories, this will become difficult to manage and
easy to forget. Instead, we can use a feature of git which allows different
configurations based on our directory structures.

Our `~/.gitconfig` file might look like this:

```
[user]
name = Simba Lion
email = [email protected]
[includeIf "gitdir:~/my-company/"]
path = ~/my-company/.gitconfig
```

This sets our default email (which, in this case, is for a personal
account). If we have repositories in the `~/my-company` directory, we'll load an
additional git config file which is located at `~/my-company/.gitconfig`. That
file might look like:

```
[user]
email = [email protected]
```

Now when our user commits changes, it will use their personal email by default,
or their corporate email for any repositories within the `~/my-company`
folder. Note that the name attribute is inherited from the base configuration,
so we don't need to double specify it.

0 comments on commit 09a527d

Please sign in to comment.