Skip to content
$ gitswitch
Nord
★ star

Commit Identity Switching

gitswitch instantly changes the name and email used for your git commits by updating:

git config --global user.name "Your Name"
git config --global user.email "you@example.com"

Every commit you make will be attributed to the switched identity.

Without gitswitch, switching identities means:

  1. Opening a terminal
  2. Running git config --global user.name "..."
  3. Running git config --global user.email "..."
  4. Making a commit
  5. If you forget step 1-3, your commit is attributed to the wrong identity

Worse: you only realize it after pushing. Wrong attribution is permanent.

Terminal window
gitswitch work
# Now all your commits are attributed to work identity until you switch

No config files. No manual edits. One command.

When you switch profiles, gitswitch:

  1. Updates git config --global user.name
  2. Updates git config --global user.email
  3. Optionally updates SSH key (sets core.sshCommand)
  4. Optionally updates GPG signing key
  5. Optionally calls gh auth switch for GitHub CLI

The commit identity is applied globally. Every repo you work in will use the active identity until you switch again.

You can set a per-repo identity if needed:

Terminal window
cd ~/my-special-repo
git config --local user.name "Special Name"
git config --local user.email "special@example.com"

Git looks up the identity in this order:

  1. Local config (--local) — repo-specific
  2. Global config (--global) — gitswitch manages this
  3. System config (--system)

Repo-local settings always take priority.

If a repo always needs a specific identity, pin it:

Terminal window
cd ~/my-work-repo
gitswitch pin work

Now when you enter this repo, gitswitch will nudge you to switch to work.

Add your profiles:

Terminal window
gitswitch add personal "Alice" alice@gmail.com \
--ssh-key ~/.ssh/id_personal
gitswitch add work "Alice" alice@company.com \
--ssh-key ~/.ssh/id_work
Terminal window
# Check current identity
gitswitch current
# → personal / alice@gmail.com
# Switch to work
gitswitch work
gitswitch current
# → work / alice@company.com
# Make commits — they're attributed to alice@company.com
git commit -m "Add feature"
# Later, switch back
gitswitch personal
gitswitch current
# → personal / alice@gmail.com

After switching, check your current config:

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

Or use gitswitch:

Terminal window
gitswitch current

Check:

  1. Are you using a repo-local override? (git config --local user.email)
  2. Did you forget to switch? (gitswitch current)
  3. Is your SSH key sending the right identity? (SSH key email might differ from git config)

Solution:

Terminal window
# Remove local override if set
git config --local --unset user.email
# Switch the right profile
gitswitch work
# Verify
gitswitch current

If you have multiple GPG keys, make sure your profile’s GPG key matches:

Terminal window
gitswitch add work "Alice" alice@company.com \
--gpg-key 1234567890ABCDEF

After switching, verify:

Terminal window
git config --global user.signingkey

SSH Key Management
GPG Signing
Identity Awareness