Skip to content
WorktreeWise
#git-config#worktreeConfig#git-internals#git-worktree

Per-worktree Git config

W

WorktreeWise Engineering Team

Updated Sep 20266 min read

TL;DR: The 30-Second Summary

Use Git's `extensions.worktreeConfig` feature to configure different `user.email`, `core.hooksPath`, or GPG signing keys for specific worktrees within the same repository.

The Real-Life Scenario

A developer contributes to an open-source repo for both personal and work projects. In the `oss-feature` worktree, commits must use `personal@gmail.com`, while `client-feature` requires `dev@company.com`.

By default, `git config` modifies `.git/config`, which applies globally to all worktrees in that repository. With `extensions.worktreeConfig`, Git enables per-worktree configuration files.

The Single Configuration Limitation

Running `git config user.email` in any worktree normally changes the email across the entire repository. You cannot have different Git settings per worktree without the extension.

What you see in the terminal:

terminal output
$ git config user.email "work@corp.com"
# Overwrote email for all worktrees!
🔍

Under the Hood: Git Plumbing & Architecture

Enabling `extensions.worktreeConfig` tells Git to read `.git/worktrees/<name>/config.worktree` in addition to the main `.git/config`.

Quick Command Recipes

Copy and adapt these commands directly in your terminal:

Enable per-worktree configuration extension

Enables per-worktree config files in `.git/worktrees/<name>/config.worktree`.

bash
git config extensions.worktreeConfig true

Set configuration for current worktree only

Writes the setting strictly to this worktree's config file.

bash
git config --worktree user.email 'dev@personal.com'
TUTORIAL

Step-by-Step Practical Walkthrough

Follow these verified steps to safely resolve the issue and guarantee that your filesystem and Git references are in sync.

1

Enable the extension

Activate worktree configuration support.

terminal
git config extensions.worktreeConfig true
2

Set worktree-specific config

Apply setting only to this worktree.

terminal
git config --worktree user.name 'Dev Agent'
3

Verify the configuration scope

Confirms the setting originates from `config.worktree`.

terminal
git config --show-origin user.name
Expected Output:
file:.git/worktrees/agent/config.worktree	Dev Agent

Edge Cases & Advanced Scenarios

Per-worktree hooks path

You can set `git config --worktree core.hooksPath .githooks/agent` to run custom hooks in specific worktrees.

⚠️

Common Mistakes to Avoid

❌ Mistake: Running `git config --local` thinking it is per-worktree

Why it causes trouble: `--local` writes to `.git/config`, affecting ALL worktrees.

What to do instead: Use `git config --worktree`.

Verification Checklist

  • `git config --worktree` writes to `.git/worktrees/<id>/config.worktree`
  • Other worktrees retain their original configuration values
💡

Senior Engineering Tips

  • WorktreeWise lets you set custom Git author, email, and shell settings per worktree directly in the UI.

Key Takeaways

  • 01.Enable `git config extensions.worktreeConfig true`.
  • 02.Use `git config --worktree <key> <val>` for worktree-scoped settings.
TOOL

How WorktreeWise Solves This Visually

WorktreeWise eliminates the manual friction and mental overhead of CLI flags. It displays real-time branch states, uncommitted modifications, active terminals, and lock statuses across all worktrees on a single visual dashboard.

WorktreeWise Settings screen configuring per-worktree options
WorktreeWise Settings screen configuring per-worktree options
W

WorktreeWise Engineering Publication

Written and curated by the core WorktreeWise team. We build developer tools that turn Git worktrees, workflows, and parallel AI coding agents into second nature.

Related Isolation Guides

View all isolation