DEV Community

Clarice Bouwer
Clarice Bouwer

Posted on

1 1

How to use a different email address in Git in sub directories

Motivation

I want to override my personal email address I use for Git with my work email address in my work directory without manually changing it each time.

Create a config file in the work directory

touch ~/path/to/work/directory/.gitconfig
Enter fullscreen mode Exit fullscreen mode
# any customization/overrides can be added here
[user]
        name = Clarice Bouwer
        email = clarice@example.com
Enter fullscreen mode Exit fullscreen mode

Update ~/.gitconfig

[includeIf "gitdir:~/path/to/work/directory/"]
    path = ~/path/to/work/directory/.gitconfig
Enter fullscreen mode Exit fullscreen mode

Verify

cd ~/
git config user.email # should be your default config email

cd ~/path/to/work/directory
git config user.email # should be your override email
Enter fullscreen mode Exit fullscreen mode

Based on Stack Overflow: Set Git config values for all child folders and Alvin Alexander: Git show change username and email address.

Image of Datadog

How to Diagram Your Cloud Architecture

Cloud architecture diagrams provide critical visibility into the resources in your environment and how they’re connected. In our latest eBook, AWS Solution Architects Jason Mimick and James Wenzel walk through best practices on how to build effective and professional diagrams.

Download the Free eBook

Top comments (1)

Collapse
 
kopseng profile image
Carl-Erik Kopseng

This works great. Been using something similar for a while

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs