Effortlessly manage multiple Git identities and SSH keys. Generate keys, save per-profile Git name/email, and switch profiles in one command. Auto-updates ~/.ssh include and your global Git config for GitHub/GitLab.
Project description
git-switch
Effortlessly manage multiple Git identities and SSH keys. Generate keys, save per-profile Git name/email, and switch profiles in one command. Auto-updates ~/.ssh include and your global Git config for GitHub/GitLab.
Usage
After installing the project in a virtual environment, run:
git-switch
You should see:
Hello from git-switch 👋
## SSH profiles utility
Manage multiple Git SSH accounts and switch keys quickly.
### Setup
```bash
git-switch ssh init
Version
Print the installed version:
git-switch --version
This creates a managed include at ~/.ssh/git-switch-managed.conf and ensures your ~/.ssh/config includes it.
Add a profile
Generate a new ed25519 key managed by this tool:
git-switch ssh add --name personal --email you@example.com --generate
If a key already exists at the generated path, either remove it or force overwrite:
git-switch ssh add --name personal --email you@example.com --generate --force
Or use an existing private key:
git-switch ssh add --name work --key-path ~/.ssh/id_ed25519_work --hosts github.com,gitlab.com
View the public key path printed, and add it to GitHub/GitLab.
List profiles
git-switch ssh list
Activate a profile
git-switch ssh use --name work # applies Git identity globally
This updates ~/.ssh/git-switch-managed.conf with the selected key for configured hosts.
Remove a profile
git-switch ssh remove --name personal
# To also delete generated keys (only if under the managed directory):
git-switch ssh remove --name personal --delete-keys --force
Profiles are stored at ~/.config/git-switch/profiles.json. Generated keys live under ~/.ssh/git-switch/<profile>/.
Store Git identity on profile
You can save Git identity per profile during add:
git-switch ssh add --name work --key-path ~/.ssh/id_ed25519_work --git-name "Your Work Name" --git-email your.name@company.com
When you run ssh use, the saved Git identity is applied automatically to your global Git config.
Update a profile's Git identity
git-switch ssh update --name personal --git-name "New Name" --git-email new@example.com
Then apply it:
git-switch ssh use --name personal
Copy a profile's public key
Copy a profile's public key to your clipboard for adding to GitHub/GitLab:
git-switch copy-key personal # copy 'personal' profile's public key
git-switch copy-key # copy the active profile's public key
This uses your OS clipboard tool (pbcopy on macOS, wl-copy/xclip on Linux, clip on Windows). If unavailable, the key is printed to stdout.
Development
Makefile commands
- Install: creates/uses a virtual environment and installs the package in editable mode
make install
# If a venv wasn't active, this creates .venv/. To activate:
source .venv/bin/activate
- Build: builds sdist and wheel into
dist/
make build
- Test with coverage: runs the full test suite and generates terminal + HTML coverage (
htmlcov/index.html)
make test
- Test an individual file or test: pass FILE to run a specific test file or node id
make test-file FILE=tests/test_cli.py
make test-file FILE=tests/test_cli.py::test_handle_copy_key_fallback_prints_key
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 git_switch_cli-0.1.2.tar.gz.
File metadata
- Download URL: git_switch_cli-0.1.2.tar.gz
- Upload date:
- Size: 15.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe6adaac9aa96d532e98b2b3cfb9b1e72ed4217bd88ea1fa15ad9e4fbca91748
|
|
| MD5 |
5ce66b9ed1618e731f6bfe16867fe4d3
|
|
| BLAKE2b-256 |
f6ff8fb0e54b7ea4598e23048e5aa13d174c28fd22884165e516a19af69dca5d
|
File details
Details for the file git_switch_cli-0.1.2-py3-none-any.whl.
File metadata
- Download URL: git_switch_cli-0.1.2-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9818f2a31302822dd9dba6038949a437708a16990f6a2ce54953d689b0c1dc67
|
|
| MD5 |
44ca96a74703b18ef87a215fde4e1f1f
|
|
| BLAKE2b-256 |
a6b2843f3a1f7ffe225c933664be87bae5284df4dc99570eed2fce97599430ca
|