Commit Identity
What a switch actually writes, and how git decides who you are
Switching
gitswitch work # or: gitswitch switch work, or enter in the TUI✓ Switched to 'work' — Alice Smith <alice@company.com>That writes, in order:
git config --global user.name "Alice Smith"
git config --global user.email "alice@company.com"
git config --global user.signingkey "<key>" # if the account has one
git config --global gpg.format ssh # only when that key is an SSH key
git config --global core.sshCommand "ssh -i <path> -o IdentitiesOnly=yes" # if it has an SSH key
gh auth switch --user alice-corp # if it has a GitHub usernameTwo things worth knowing:
- Accounts without a key clear that setting. Switching to an account with no signing key unsets
user.signingkeyandgpg.format; no SSH key unsetscore.sshCommand. So one account's setup never leaks into the next one. - The
ghstep is best-effort. Ifghisn't installed or that account isn't logged in, you get a warning and the git config still switches correctly:
warning: gh auth switch --user alice-corp: exec: "gh": executable file not found in $PATH
✓ Switched to 'work' — Alice Smith <alice@company.com>Who am I right now?
gitswitch currentwork — Alice Smith <alice@company.com> (pinned to this repo)
HTTPS credential helper: activeThe parenthetical is the important part — see Scopes. For scripts:
gitswitch current --jsonOr ask git directly:
git config --global user.name
git config --global user.emailHow git decides
Narrowest scope wins:
GIT_CONFIG_*environment variables — this terminal only- The repo's own
.git/config— where pins live ~/.gitconfig— where a plaingitswitch <name>writes/etc/gitconfig— system-wide
So a pinned repo ignores your global identity entirely. That's the point of pinning.
Check what a commit says
git log -1 --format="%an <%ae>"Fixing a wrong one
Not pushed yet:
gitswitch work
git commit --amend --reset-author --no-editMore than one commit, or already pushed:
gitswitch reauthor 3 --to work --pushOne command instead of a hand-rolled interactive rebase. Full reference in AI Coding Agents — it's the same tool whether a human or an agent made the mess.
Once pushed, attribution is permanent unless you rewrite history. Cheaper to prevent: pin the repo, or let the shell nudge catch you on the way in.
Removing a per-repo identity
If a repo has its own identity you no longer want:
gitswitch unpinThat clears user.name, user.email, user.signingkey, gpg.format, and core.sshCommand from the repo's local config, and it falls back to your global identity. (The by-hand equivalent is git config --local --unset user.email, five times over.)
Next
- Scopes — global vs. repo vs. terminal
- SSH Keys — forcing the right key
- Commit Signing — GPG or SSH signing per account