Build1 distinct publisher3 min readUpdated
A dev.to walkthrough revives a Git conditional include that has shipped since 2017. The useful part is not the trick but the two ways it fails without telling you.
The Engineer · Build desk
Compiled by The EngineerSomething wrong?How this is made
Anyone running more than one GitHub account has probably pushed a commit under the wrong email, and neither Git nor GitHub raises an objection at the time [1]. A post on dev.to argues that the durable fix is not discipline but configuration: `includeIf`, a conditional include that has been in Git since version 2.13 in 2017 [2].
The usual remedy is to run `git config user.email` inside each repository. It works, and it depends on you remembering to do it every time, which the author is blunt about not doing consistently while mid-fix and wanting to commit [3]. That is the interesting property of the failure: it is not a knowledge gap, it is a recall gap, and recall gaps scale badly. The author describes identities multiplying past two into work, personal, side projects and client work, each with its own email and SSH key, so the odds of a wrong push rise with the count [4].
`includeIf` moves the decision from memory to the filesystem. In `~/.gitconfig` you declare a `gitdir:` condition per tree and point it at a profile file, so repos under `~/dev/work/` load one config and repos under `~/dev/personal/` load another [5]. The profile is an ordinary Git config: a `[user]` block with name and email, plus a `core.sshCommand` that pins a specific key with `IdentitiesOnly=yes` [6]. Set once, evaluated on every command.
The footguns are worth more attention than the syntax, because both are silent. Trailing slashes matter: `gitdir:/home/you/dev/work` matches by prefix, so it also claims `/home/you/dev/workplace`, while the trailing slash narrows the match to repos inside that directory [7]. And relative paths in `includeIf` resolve against the config file's location, not your working directory, which the author notes is documented but easy to misread [8]. Put those together and you have traded many small chances of a per-commit mistake for one chance of a setup-time mistake that then applies itself consistently and invisibly [14].
The SSH side has a matching trap. GitHub refuses the same key on two accounts, rejecting it with "Key is already in use" [9]. But with several keys loaded in `ssh-agent`, SSH may offer the wrong one first, and GitHub authenticates you as the owner of whichever key it accepted [10]. `IdentitiesOnly=yes` is what forces SSH to use only the key named for that identity and ignore the agent [11]. That is the part most hand-rolled setups miss, and it explains commits that carry the right email but land through the wrong account.
The author also ships a bash script, `git-persona`, which takes one command per identity to generate the key, write the profile, add the `includeIf` rule and print the public key for GitHub, plus subcommands to show the current identity, list identities and override for one repo [12]. Their pitch is auditability rather than features: no dependencies, no runtime, no daemon, roughly 600 lines of bash meant to be read in ten minutes, on the argument that anything managing your SSH keys should be verifiable [13].
Worth checking before you trust it: a repo cloned outside every configured prefix matches no condition and quietly falls back to your global identity, which is exactly the case that used to bite you [15]. Verify inside a fresh clone rather than assuming, and check `core.sshCommand` as well as `user.email`.
Follow any of these and your For You feed starts watching them — no settings page required.
Ranked by verification strength, evidence, and original report placement.
Developers with more than one GitHub account commonly push a commit with the wrong email; Git did not warn and GitHub did not warn, and the mistake is typically found later in the commit history.
Git 2.13 introduced includeIf in 2017; it lets you apply different configurations based on which directory you are in.
The standard fix is to run git config user.email in each repo; it works but relies on remembering to do it every single time, which the author says you will not do consistently, especially mid-fix when you just want to commit and move on.
The author describes having more than two identities: work, personal, side projects, client work and experiments, each tied to its own GitHub account, email and SSH key, with the odds of pushing under the wrong one rising as repo and identity counts grow.
Setup is done once in ~/.gitconfig with entries such as [includeIf "gitdir:/home/you/dev/work/"] path = ~/.config/git-persona/profiles/work.gitconfig, so any repo under ~/dev/work/ automatically uses the work identity and any repo under ~/dev/personal/ uses the personal one, with no per-repo config.
Each profile config is a regular git config file containing a [user] block with name and email plus [core] sshCommand = ssh -i ~/.ssh/id_ed25519_git_work -o IdentitiesOnly=yes.
Evidence-backed comparisons of source perspectives and observed adoption signals. Read the methodology
Which Builder, Operator, and Investor concerns the observed source mix emphasized—not a truth score.
Evidence, demonstrated adoption, hype gap, incentives, and confidence are assessed independently, each on its own current evidence. How these are measured.
Mechanism well specified, tool claims unverified
The Git and GitHub behaviours are stated precisely enough to test: the includeIf gitdir syntax, prefix-versus-exact matching on the trailing slash, relative-path resolution against the config file, GitHub's "Key is already in use" rejection, and ssh-agent key-offer order defeated by IdentitiesOnly=yes. These are internally consistent and reproducible from the snippets given. Evidence is capped because the cluster contains exactly one source, that source is the tool author, no Git documentation or third-party reproduction is cited, and the tool's own properties (600 lines, no dependencies, cross-platform testing) rest solely on self-report.
Feature universally available, tool adoption unmeasured
The only adoption fact in the cluster is the author's own publication of git-persona under MIT with an install script; no stars, installs, users, teams or deployments are disclosed. The underlying includeIf capability has shipped in every Git since 2.13, so availability is effectively universal, but availability is not usage and the cluster carries no data on how widely the directory-scoped identity pattern is actually practised. The score reflects one self-published release plus broad feature availability and nothing more.
Headline overpromises, body is honest
Modestly overstated. The title promises you will 'never commit with the wrong Git identity again' and the piece ends with a curl install line for the author's tool, but the mechanism it sells is a nine-year-old built-in whose correctness depends on setup the article itself says fails silently in two ways, and which does nothing for repos cloned outside the declared prefixes. Offsetting the promotional framing, the body is unusually candid: it names the trailing-slash and relative-path traps, explains the ssh-agent key-offer hazard, and tells manual users to prefer absolute paths, which keeps the gap small rather than large.
Author promotes own tool in own post
The piece is self-published on dev.to by the author of git-persona and terminates in a curl-piped install command plus a repo link, so the writing has a direct distribution incentive for the author's project. The incentive is disclosed rather than hidden — the tool is named throughout, the licence is stated, and readers are invited to read the source — and no vendor, sponsor or commercial relationship is present, which keeps this short of the highest band.
Mechanism claims solid, everything else thin
Confidence is moderate. The technical core is specific, self-consistent and easy for a reader to reproduce locally, which supports the claims about includeIf semantics, GitHub key reuse and ssh-agent behaviour. It is held down by the single-publisher cluster, the author's stake in the tool being recommended, the total absence of usage data, and two derived conclusions (silent single-point setup failure, global-identity fallback outside declared prefixes) that follow from the article's model rather than from anything it states outright.
build
AI-written code fails the same four ways, and every gate you own reports green1 distinct publisher
build
Your reviewing model is reading the diff when it should be reading the session1 distinct publisher
build
The AI tell is installed during fine-tuning. Humanizer tools edit the output instead.1 distinct publisher
build
Exit 0 is not a health check: three weeks of macOS backups that copied nothing1 distinct publisher
Distinct publishers with included, body-backed reporting in this cluster.
dev.to
1 article · August 20, 2026