<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Configuration on MoskitoHero</title><link>/tags/configuration/</link><description>Recent content in Configuration on MoskitoHero</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Mon, 01 Jun 2026 16:22:00 +0200</lastBuildDate><atom:link href="/tags/configuration/index.xml" rel="self" type="application/rss+xml"/><item><title>Directory-based git config rules</title><link>/post/directory-based-git-config-rules/</link><pubDate>Mon, 01 Jun 2026 16:22:00 +0200</pubDate><guid>/post/directory-based-git-config-rules/</guid><description>I have found a way to alter my git config based on the directory I am working from. Pretty simple, yet very handy.</description><content:encoded><![CDATA[<div class="paragraph">
<p>Like most devs, I use Git both for personal and work stuff, but I need to use distinct user details in each case to sign-off my commits. I have a global <code>.gitconfig</code> that define my personal email as <code>user.email</code>, but whenever I need to pull a new work project, I have to remember to set it to a different value locally. Which I keep forgetting to do.</p>
</div>
<div class="paragraph">
<p>So I have found a way to alter my git config based on the directory I am working from. All you need to do is add these lines to your <code>~/.gitconfig</code>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="toml"><span class="k">[</span><span class="n">user</span><span class="k">]</span>
  <span class="n">name</span> <span class="o">=</span><span class="w"> </span><span class="err">My Name
  email = personal@email.com

# Use work email for repositories under ~/dev/work
</span><span class="p">[</span><span class="err">includeIf </span><span class="s">&#34;gitdir:~/dev/work/&#34;</span><span class="p">]</span>
  <span class="n">path</span> <span class="o">=</span><span class="w"> </span><span class="err">~/.gitconfig-work</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>And edit <code>.gitconfig-work</code>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="toml"><span class="k">[</span><span class="n">user</span><span class="k">]</span>
  <span class="n">email</span> <span class="o">=</span><span class="w"> </span><span class="err">work-email@mycompany.com</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>I think this also applies to other git config values, so feel free to experiment!</p>
</div>
]]></content:encoded></item></channel></rss>