-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from justinabrahms/corporate-vs-personal
Document how to separate work vs personal personas in gitconfig.
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |