Git Account Switcher - Manage multiple Git SSH accounts easily
Project description
Git Account Switcher
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.
Features
- 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)
Installation
pip install gitacc-switcher
From source
git clone https://github.com/ktechhub/gitacc-switcher.git
cd gitacc-switcher
pip install .
Quick start
# 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 check
Commands
gitacc add [--type TYPE]
Add 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 ed25519
gitacc switch <account> / gitacc <account>
Switch 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 # shorthand
The SSH agent must already be running (
eval $(ssh-agent)). If it isn't, gitacc will tell you.
gitacc list
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)
gitacc remove [account]
Remove an account and its SSH keys. Prompts for confirmation.
gitacc remove mywork
gitacc remove # prompts for account name
gitacc update <account> [--name NAME] [--email EMAIL]
Update 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 both
gitacc init <account>
Bind 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 mywork
gitacc verify
Check whether the current Git identity matches the account expected by this repository.
gitacc verify
gitacc logout
Kill the SSH agent and unset the global Git user config.
gitacc logout
gitacc autocomplete install
Install tab-completion for your shell (bash or zsh). After running, restart your shell or source your profile.
gitacc autocomplete install
Completions cover: all command names, account names (for switch, remove, init, update), and key types (for add --type).
gitacc --version
gitacc --version
# gitacc 0.1.0
How pre-commit validation works
gitacc 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.
File layout
| 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
Requirements
- Python 3.8+
- Git
- SSH tools (
ssh-keygen,ssh-agent,ssh-add) inPATH
Changelog
See CHANGELOG.md for a full history of changes.
Contributing
See CONTRIBUTING.md for setup instructions, commit conventions, and the PR process.
License
MIT — see LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gitacc_switcher-1.0.1.tar.gz.
File metadata
- Download URL: gitacc_switcher-1.0.1.tar.gz
- Upload date:
- Size: 26.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f389d89bcf337fc4d081d8784794fe36da3a7736222e27223e15469e298f4f84
|
|
| MD5 |
4481cbdbfd5946b9e06d38d7b1c45e47
|
|
| BLAKE2b-256 |
e9ad502e825ed971f5476679a59cded033f07881381fcc705b648d74547f2f45
|
File details
Details for the file gitacc_switcher-1.0.1-py3-none-any.whl.
File metadata
- Download URL: gitacc_switcher-1.0.1-py3-none-any.whl
- Upload date:
- Size: 29.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e653313c8f947c303eb5a8022c301925c4a903b64af2c9e5d80436b6d6a1ad48
|
|
| MD5 |
122affc5332506b8a0113bbe26f5f645
|
|
| BLAKE2b-256 |
324c33ce0123dd2684c043733c9d3282aff0e19a26c00099d95d6bccb5d03a70
|