// docs
Accounts

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 username

Two things worth knowing:

  • Accounts without a key clear that setting. Switching to an account with no signing key unsets user.signingkey and gpg.format; no SSH key unsets core.sshCommand. So one account's setup never leaks into the next one.
  • The gh step is best-effort. If gh isn'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 current
work — Alice Smith <alice@company.com>  (pinned to this repo)
HTTPS credential helper: active

The parenthetical is the important part — see Scopes. For scripts:

gitswitch current --json

Or ask git directly:

git config --global user.name
git config --global user.email

How git decides

Narrowest scope wins:

  1. GIT_CONFIG_* environment variables — this terminal only
  2. The repo's own .git/config — where pins live
  3. ~/.gitconfig — where a plain gitswitch <name> writes
  4. /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-edit

More than one commit, or already pushed:

gitswitch reauthor 3 --to work --push

One 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 unpin

That 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

On this page