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).
In this repository14 other files it gives its agents.
- AGENTS.mdAGENTS.md
- codex-proxySkill
- executor-plansSkill
- executor-reviewsSkill
- git-conventionsSkill
- oh-my-posh-setupSkill
- scheduling-codex-window-startsSkill
- skill-comparisonSkill
- visualizing-leetcode-solutionsSkill
- windows-fe-dev-setupSkill
- ask-orchardSkill
- decide-before-doingSkill
- plan-to-docsSkill
- review-to-docsSkill
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
- Distinctive: line 46
Add more blocks for other roots:
- Very specific: line 54
Create matching files (~/.gitconfig-acme, etc.) with the identity for that folder.
- Very specific: line 57
Always include the trailing / in gitdir: when targeting a folder tree.
- Very specific: line 58
Use absolute or ~ paths; avoid environment variables in gitdir patterns.
≈ “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.
Files
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 configchanges - Want to enforce a default global identity but override for certain directories
- Supporting multiple clients/organizations where repos live under known paths
Quick Start
- Create a per-identity config file (example for
~/work):# ~/.gitconfig-work [user] name = Your Work Name email = your.work@example.com - Reference it from the global config with includeIf:
Notes:# ~/.gitconfig [user] name = Your Default Name email = your.default@example.com [includeIf "gitdir:~/work/"] path = ~/.gitconfig-work- Trailing slash after the directory ensures subfolders match.
- Order matters: global defaults are read first; include overrides when path matches.
- Test resolution:
Expect work repos to show the override, others to show the global defaults.git -C ~/work/some-repo config user.name git -C ~/work/some-repo config user.email git -C ~/personal/some-repo config user.name
Multiple Directories
Add more blocks for other roots:
[includeIf "gitdir:~/clients/acme/"]
path = ~/.gitconfig-acme
[includeIf "gitdir:~/oss/"]
path = ~/.gitconfig-ossCreate matching files (~/.gitconfig-acme, etc.) with the identity for that folder.
Tips & Gotchas
- Always include the trailing
/ingitdir:when targeting a folder tree. - Use absolute or
~paths; avoid environment variables ingitdirpatterns. - 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 ...), butincludeIfis better for folder-wide rules.
Verification Checklist
- Global
user.name/user.emailstill return defaults outside scoped folders. - Inside each targeted folder,
git config user.*reflects the intended identity. git config --show-origin --get user.emailpoints to the expected include file when inside matched repos.
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
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.

