Commit Identity Switching
What it does
Section titled “What it does”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.
Why you need this
Section titled “Why you need this”The problem
Section titled “The problem”Without gitswitch, switching identities means:
- Opening a terminal
- Running
git config --global user.name "..." - Running
git config --global user.email "..." - Making a commit
- 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.
The solution
Section titled “The solution”gitswitch work# Now all your commits are attributed to work identity until you switchNo config files. No manual edits. One command.
How it works
Section titled “How it works”When you switch profiles, gitswitch:
- Updates
git config --global user.name - Updates
git config --global user.email - Optionally updates SSH key (sets
core.sshCommand) - Optionally updates GPG signing key
- Optionally calls
gh auth switchfor GitHub CLI
The commit identity is applied globally. Every repo you work in will use the active identity until you switch again.
Repo-specific overrides
Section titled “Repo-specific overrides”You can set a per-repo identity if needed:
cd ~/my-special-repogit config --local user.name "Special Name"git config --local user.email "special@example.com"Git looks up the identity in this order:
- Local config (
--local) — repo-specific - Global config (
--global) — gitswitch manages this - System config (
--system)
Repo-local settings always take priority.
Identity pinning
Section titled “Identity pinning”If a repo always needs a specific identity, pin it:
cd ~/my-work-repogitswitch pin workNow when you enter this repo, gitswitch will nudge you to switch to work.
Example: Switching between accounts
Section titled “Example: Switching between accounts”Add your profiles:
gitswitch add personal "Alice" alice@gmail.com \ --ssh-key ~/.ssh/id_personal
gitswitch add work "Alice" alice@company.com \ --ssh-key ~/.ssh/id_workWorkflow
Section titled “Workflow”# Check current identitygitswitch current# → personal / alice@gmail.com
# Switch to workgitswitch workgitswitch current# → work / alice@company.com
# Make commits — they're attributed to alice@company.comgit commit -m "Add feature"
# Later, switch backgitswitch personalgitswitch current# → personal / alice@gmail.comVerify changes
Section titled “Verify changes”After switching, check your current config:
git config --global user.namegit config --global user.emailOr use gitswitch:
gitswitch currentCommon issues
Section titled “Common issues”Commits still attributed to wrong email
Section titled “Commits still attributed to wrong email”Check:
- Are you using a repo-local override? (
git config --local user.email) - Did you forget to switch? (
gitswitch current) - Is your SSH key sending the right identity? (SSH key email might differ from git config)
Solution:
# Remove local override if setgit config --local --unset user.email
# Switch the right profilegitswitch work
# Verifygitswitch currentCommits are signed by wrong GPG key
Section titled “Commits are signed by wrong GPG key”If you have multiple GPG keys, make sure your profile’s GPG key matches:
gitswitch add work "Alice" alice@company.com \ --gpg-key 1234567890ABCDEFAfter switching, verify:
git config --global user.signingkey