Claude Code Committing With the Wrong Git Email?
Claude Code commits with whatever git is set to in that folder, not your Claude account's email. How to check it, fix it per folder, and repair past commits.

Claude Code doesn't have a git identity of its own. When it commits, it runs git commit in your folder, and git stamps the commit with whatever name and email it finds there: your global ~/.gitconfig, the repository's own config, or git's environment variables. Which Claude account you're signed in to plays no part. So if your client work lands under your personal email, change git's settings for that folder.
This guide shows how to see which email a commit will get, three ways to make it right per folder, and how to repair commits that already went out with the wrong one.
Why it happens#
Most people have one email in ~/.gitconfig, set years ago. Then they add a work or client Claude account, open Claude Code in the client's repository, and expect the commits to follow the account. They don't: Claude Code's commit is an ordinary git commit, and git only knows the email you gave it.
Two things make this easy to miss:
- The Co-Authored-By line. By default Claude Code adds a
Co-Authored-By: Claudetrailer to each commit, so GitHub shows Claude next to the author. That trailer is the only part Claude Code writes. The author and committer are still yours, from git. - No email set at all. If git has no
user.emailfor a folder, it builds one from your Mac's user and host name (something like[email protected]) and prints a warning that is easy to scroll past in a long session. GitHub can't link that email to any account.
Step 1: check which email git will use#
Open a terminal in the repository and run:
git var GIT_AUTHOR_IDENT
git config --show-origin user.email
git log -3 --format='%an <%ae> %s'
The first line prints the name and email git will put on the next commit, environment variables included. The second shows which config file the email comes from, your global one or the repository's. The third shows who the last three commits are by. Run these in the same kind of shell Claude Code runs in: a variable exported only inside Claude Code won't show up in a plain Terminal.
Step 2: pick a fix#
Option 1: set the email in that repository#
The quickest fix for one repository:
git config user.name "Your Name"
git config user.email "[email protected]"
Without --global, this writes to the repository's own .git/config and wins over ~/.gitconfig. It only covers this one clone, so you'll have to repeat it for each new clone, and it's easy to forget on the next one.
Option 2: one email per folder with includeIf#
If all of a client's code lives under one folder, git can switch the email by itself. Add this to ~/.gitconfig:
[includeIf "gitdir:~/Clients/Acme/"]
path = ~/.gitconfig-acme
And in ~/.gitconfig-acme:
[user]
name = Your Name
email = [email protected]
Every repository under ~/Clients/Acme/ now commits as [email protected], including clones you make next month. The trailing slash matters: it means "this folder and everything below it". Without it, git compares the pattern with the .git folder's own path and nothing matches. Note that gitdir: is case-sensitive even though macOS paths aren't; gitdir/i: ignores case. This is the fix most people want, and it works for every tool that commits, including Claude Code.
Option 3: Claude Code's env setting#
Claude Code passes the variables in the env key of its settings files to every command it runs, and git's own variables beat every config file. So a repository's .claude/settings.local.json can carry the identity:
{
"env": {
"GIT_AUTHOR_NAME": "Your Name",
"GIT_AUTHOR_EMAIL": "[email protected]",
"GIT_COMMITTER_NAME": "Your Name",
"GIT_COMMITTER_EMAIL": "[email protected]"
}
}
Use this when you want Claude Code's commits under one email and your own manual commits under another. Keep it in settings.local.json rather than the shared .claude/settings.json, and check that .gitignore covers it: Claude Code ignores the file when it creates it, but one you make by hand isn't ignored. Restart Claude Code after editing it.
If the email should follow your Claude account#
Sometimes the folder isn't the right line to draw. You might work on the same open-source repository from your personal account and your employer's account, and want the commits from each account under its own email.
Clawdrobe is a Mac app that runs several Claude accounts side by side, each with its own Claude Desktop app and its own Claude Code sign-in. Since Clawdrobe 1.7, each added account has Commit As in its Tools: a name and an email for the commits Claude Code makes as that account.
- Select the added account in Clawdrobe's sidebar and find Commit As under Tools.
- Type the name and email and press Return.
- Start Claude Code as that account: with the account's
claude-<name>command in Terminal, the Tools button, or plainclaudein one of the account's folders (Tools → Folders, which needs one line in~/.zshrc).
Clawdrobe sets git's author and committer variables only in those sessions and folders. Your ~/.gitconfig stays as it is, and if you've set git variables in your shell yourself, Clawdrobe leaves them alone. An env block from Option 3 in a repository's settings still wins inside that repository, because Claude Code's env overrides the shell.
What it doesn't cover:
- The main account. Commit As is for added accounts. Your main account commits with your normal git settings, which is usually what you want for personal work.
- The Code tab in Claude Desktop. Sessions started from the app's Code tab don't get the Commit As email. For those, use
includeIf(Option 2). - Sessions that started before the change. Restart any running Claude Code session after editing Commit As, and open a new Terminal window if you're inside one of the account's folders.
Clawdrobe is free for two accounts with every feature, and Clawdrobe Pro is a one-time $10 for more. It needs macOS 26 or later and isn't affiliated with Anthropic.
Fixing commits that already went out#
Change the email first (Step 2), or the repair will reuse the wrong one. If you chose Option 3, the new email only exists inside Claude Code: ask Claude Code to run the repair, or export the four GIT_* variables in your Terminal first.
The last commit only, not pushed yet:
git commit --amend --reset-author --no-edit
Several commits on your branch, where main is the branch you started from:
git rebase -r --exec 'git commit --amend --reset-author --no-edit' $(git merge-base main HEAD)
-r keeps any merge commits, and starting from the merge base keeps your branch where it is instead of moving it onto today's main.
Both rewrite the commits, so they get new hashes. On a branch only you use, push with git push --force-with-lease. On a branch others have pulled, or on main, don't rewrite: leave the history and fix the setup for the next commit. Rewriting shared history causes more trouble for your team than a wrong email does.
If the commits are already merged and only GitHub's view bothers you, there's a gentler route: add and verify the email that was used under your GitHub account's Settings → Emails, and GitHub links those commits to you. That only works when the email is really yours and can receive mail, such as an old work address; a made-up [email protected] can't be verified.
Pitfalls#
- Worktrees in another folder.
includeIf "gitdir:…"matches the main repository's.git, so a worktree you put elsewhere still follows the main clone's rule. - Hiding Claude's trailer. If the problem is the Co-Authored-By line rather than your email, that's a different setting:
attributionin Claude Code's settings changes or removes it. - The wrong GitHub login. The commit email decides who wrote the commit. Who can push is decided by your git credentials or
ghlogin, which are separate. Getting the email right doesn't stop a push to a client repository with your personal GitHub token.
Quick answers#
Does Claude Code use my Claude account's email for commits? No. It uses git's settings in the folder. Your Claude login is never put on the commit.
Can I stop Claude Code from adding itself as a co-author?
Yes, with the attribution setting. Setting it to false hides the trailer and the pull request line, but only on Claude Code v2.1.281 or later; older versions skip the whole settings file that holds it. In a file older versions also read, set commit and pr to empty strings instead.
Which fix should I use?
One client per folder: includeIf. Claude's commits only: the env setting in settings.local.json. Commits that should follow the Claude account: Clawdrobe's Commit As.
For running your accounts side by side in the first place, see Claude work and personal account, and for picking the account per folder, a different account for each project.
More from the blog
Run several Claude Code sessions at once without edits colliding: one git worktree per session, agent view for background tasks, and what it does to limits.
Claude Team costs $25 a seat a month ($20 billed yearly) for 2 to 150 people. What Standard and Premium seats get, how limits work, and Team vs Pro.
Track your Claude usage with Settings → Usage, Claude Code's /usage and status line, ccusage, or Clawdrobe for several accounts. What each one shows and misses.
Every Claude account, side by side
Clawdrobe is free for two accounts. macOS 26 or later · Apple silicon and Intel.

