A Python CLI tool to easily switch between multiple Git SSH accounts. Manage multiple Git accounts with separate SSH keys and switch between them seamlessly.
- Manage multiple Git accounts with separate SSH keys
- Switch between accounts easily — one command, no fuss
- Generate SSH keys automatically (rsa, ed25519, ecdsa, and more)
- Optional passphrase support for SSH keys
- Colored terminal output with active account indicator
- Pre-commit hook to prevent commits with the wrong account
- Shell autocomplete for bash and zsh
- Cross-platform support (Linux / macOS)
pip install gitacc-switchergit clone https://github.com/ktechhub/gitacc_switcher.git
cd gitacc_switcher
pip install .# 1. Add your accounts
gitacc add # prompts for name, email, optional passphrase
gitacc add --type ed25519 # specify key type
# 2. Switch between them
gitacc switch work # full form
gitacc work # shorthand — same thing
# 3. See what's registered (active account is marked with *)
gitacc list
# 4. Prevent wrong-account commits in a repo
gitacc init work # sets expected account + installs pre-commit hook
gitacc verify # manual checkAdd a new Git account. Prompts for:
- Account identifier (used in key filename and as a reference)
- Git display name (defaults to account identifier)
- Optional SSH key passphrase
Available key types: rsa (default), ed25519, ecdsa, ecdsa-sk, ed25519-sk, dsa
gitacc add
gitacc add --type ed25519Switch to a registered account. Clears all keys from the SSH agent, loads only this account's key, and sets git config --global user.name/email.
gitacc switch mywork
gitacc mywork # shorthandThe SSH agent must already be running (
eval $(ssh-agent)). If it isn't, gitacc will tell you.
List all registered accounts. The currently active account (matching global git config) is marked with *.
gitacc list
# Registered accounts:
# * work → Git name: Jane Doe (jane@company.com) (active)
# - personal (jane@personal.com)Remove an account and its SSH keys. Prompts for confirmation.
gitacc remove mywork
gitacc remove # prompts for account nameUpdate the Git display name and/or email for an existing account. Prompts for any field not provided as a flag.
gitacc update mywork --name "Jane Doe"
gitacc update mywork --email "jane@newcompany.com"
gitacc update mywork # prompts for bothBind the current repository to an account and install a pre-commit hook. Any commit attempt with a mismatched account will be blocked.
cd ~/projects/work-repo
gitacc init myworkCheck whether the current Git identity matches the account expected by this repository.
gitacc verifyKill the SSH agent and unset the global Git user config.
gitacc logoutInstall tab-completion for your shell (bash or zsh). After running, restart your shell or source your profile.
gitacc autocomplete installCompletions cover: all command names, account names (for switch, remove, init, update), and key types (for add --type).
gitacc --version
# gitacc 0.1.0gitacc init myworkstoresgitacc.expected-account = myworkin the repo's local git config and writes a pre-commit hook.- On every
git commit, the hook reads~/.gitaccand compares the expected account's name/email against the currentgit config user.*. - If they don't match, the commit is blocked with a helpful message pointing to
gitacc switch.
| Path | Purpose |
|---|---|
~/.gitacc |
Stores all account entries (INI format) |
~/.ssh/id_<type>_<account> |
Private SSH key per account |
~/.ssh/id_<type>_<account>.pub |
Public SSH key per account |
~/.gitacc format:
[mywork]
name = Jane Doe
email = jane@company.com
private_key = /home/jane/.ssh/id_ed25519_mywork
public_key = /home/jane/.ssh/id_ed25519_mywork.pub- Python 3.8+
- Git
- SSH tools (
ssh-keygen,ssh-agent,ssh-add) inPATH
See CHANGELOG.md for a full history of changes.
See CONTRIBUTING.md for setup instructions, commit conventions, and the PR process.
MIT — see LICENSE for details.