agentleFS
OrchardxyzOrchardxyz/agent-skills/skills/deprecated/git-conditional-identities/SKILL.md

git-conditional-identities

Skill0 starsChanged 4 months agoMITView on GitHub

Use when Git needs to switch user.name and user.email automatically based on repository location (per-folder identities via includeIf gitdir).

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Add more blocks for other roots:

    line 46
  2. Very specific:

    Create matching files (~/.gitconfig-acme, etc.) with the identity for that folder.

    line 54
  3. Very specific:

    Always include the trailing / in gitdir: when targeting a folder tree.

    line 57
  4. Very specific:

    Use absolute or ~ paths; avoid environment variables in gitdir patterns.

    line 58

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Git Conditional Identities

Overview

Automatically switch Git user.name and user.email based on repo location using includeIf.gitdir. Keep a global default while assigning per-folder identities for workspaces, clients, or personal projects.

When to Use

  • Need different commit identities for specific folders (e.g., work vs personal) without manual git config changes
  • Want to enforce a default global identity but override for certain directories
  • Supporting multiple clients/organizations where repos live under known paths

Quick Start

  1. Create a per-identity config file (example for ~/work):
    # ~/.gitconfig-work
    [user]
        name = Your Work Name
        email = your.work@example.com
  2. Reference it from the global config with includeIf:
    # ~/.gitconfig
    [user]
        name = Your Default Name
        email = your.default@example.com
    
    [includeIf "gitdir:~/work/"]
        path = ~/.gitconfig-work
    Notes:
    • Trailing slash after the directory ensures subfolders match.
    • Order matters: global defaults are read first; include overrides when path matches.
  3. Test resolution:
    git -C ~/work/some-repo config user.name
    git -C ~/work/some-repo config user.email
    git -C ~/personal/some-repo config user.name
    Expect work repos to show the override, others to show the global defaults.

Multiple Directories

Add more blocks for other roots:

[includeIf "gitdir:~/clients/acme/"]
    path = ~/.gitconfig-acme

[includeIf "gitdir:~/oss/"]
    path = ~/.gitconfig-oss

Create matching files (~/.gitconfig-acme, etc.) with the identity for that folder.

Tips & Gotchas

  • Always include the trailing / in gitdir: when targeting a folder tree.
  • Use absolute or ~ paths; avoid environment variables in gitdir patterns.
  • The first matching include wins for settings defined there; unspecified keys fall back to global defaults.
  • To see which file set a value: git config --show-origin --get user.name.
  • For single-repo overrides, you can set local config inside that repo (git config user.name ...), but includeIf is better for folder-wide rules.

Verification Checklist

  • Global user.name/user.email still return defaults outside scoped folders.
  • Inside each targeted folder, git config user.* reflects the intended identity.
  • git config --show-origin --get user.email points to the expected include file when inside matched repos.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.