GuideJuly 22, 20256 min read

How to Keep Work and Personal Configs Separate on One Machine

Your work git email is showing up in personal commits. Your personal SSH key is authenticating against work repos. ConfigSync profiles fix this permanently.

The Problem: Identity Leaks

If you use one machine for both work and personal projects, you have almost certainly committed to a personal repo with your work email. Or pushed to a work repo using your personal SSH key. These identity leaks are more than embarrassing — they can violate corporate security policies and expose your personal email to coworkers.

The root cause is simple: tools like git read from a single global config file. When you set user.email in ~/.gitconfig, that email applies everywhere. Conditional includes help, but they are fragile and require manual setup on every machine.

ConfigSync Profiles: Isolated Contexts

A ConfigSync profile is a named context that carries its own variables, environment overrides, and path associations. When a profile is active, its settings take precedence over global defaults. Create one for each context:

Create work and personal profiles
# Work profile, activated when you're in ~/work configsync profile create work --path ~/work --env production # Personal profile for everything else configsync profile create personal --path ~/personal --env development

The --path flag is the key. When you cd into ~/work or any subdirectory, ConfigSync automatically activates the work profile. No manual switching required.

Profile Auto-Switching

ConfigSync resolves the active profile using a priority chain: the --profile flag wins first, then the CONFIGSYNC_PROFILE environment variable, then a .configsync-profile file (walking up parent directories), then the explicitly set active profile, and finally path-based matching.

For most developers, path-based matching handles everything. Put work repos under ~/work and personal repos under ~/personal. ConfigSync detects your current directory and activates the right profile automatically.

Different Git Emails via Templates

Set profile-specific variables for each context:

Set git email per profile
configsync profile set-var work GIT_EMAIL "sean@company.com" configsync profile set-var personal GIT_EMAIL "sean@personal.dev"

Then use a template in your .gitconfig:

~/.gitconfig template
[user] name = Sean email = {{vars.GIT_EMAIL}} {{#if tags contains "work"}} [url "git@github-work:"] insteadOf = git@github.com: {{/if}}

When ConfigSync renders this template, it substitutes the correct email based on which profile is active. The conditional block ensures work-specific URL rewrites only appear when the work profile is in use.

Separate .env Overrides Per Profile

Beyond git configuration, profiles can carry entirely different environment variable overrides. This is critical when your work and personal projects use different API keys, database URLs, or service endpoints:

Set environment overrides
# Work profile: production API keys configsync profile set-env-override work DATABASE_URL "postgres://work-db.internal:5432/app" configsync profile set-env-override work API_KEY "sk-work-abc123" # Personal profile: development keys configsync profile set-env-override personal DATABASE_URL "postgres://localhost:5432/dev" configsync profile set-env-override personal API_KEY "sk-personal-xyz789"

When you pull your configuration, the active profile determines which overrides apply. Work secrets stay in work projects. Personal secrets stay in personal projects. No cross-contamination.

Complete Setup: Work + Personal in 5 Minutes

Here is the full sequence to set up isolated work and personal configurations from scratch:

Full setup
# 1. Create profiles with path-based auto-switching configsync profile create work --path ~/work --env production configsync profile create personal --path ~/personal --env development # 2. Set profile-specific variables configsync profile set-var work GIT_EMAIL "sean@company.com" configsync profile set-var work SSH_KEY "~/.ssh/id_work" configsync profile set-var personal GIT_EMAIL "sean@personal.dev" configsync profile set-var personal SSH_KEY "~/.ssh/id_personal" # 3. Add your git config as a template configsync add file ~/.gitconfig --template # 4. Push from each context cd ~/work && configsync push -m "work config" cd ~/personal && configsync push -m "personal config" # 5. On a new machine, pull and both profiles restore configsync pull
Tip: You can verify which profile is active at any time by running configsync profile show. It displays the active profile name, its variables, and how it was resolved.

No More Identity Leaks

With ConfigSync profiles, work and personal configurations are fully isolated. Your git email switches automatically when you move between directories. Your SSH keys, API tokens, and environment variables all follow the same boundaries. Set it up once, push it to the cloud, and every machine you use gets the same clean separation.

Ready to try ConfigSync?

Sync your entire dev environment across machines in minutes. Free forever for up to 3 devices.