Manage multiple Git accounts safely using separate SSH keys for each account.
If you have multiple GitHub/Codeberg/GitLab accounts (e.g., work + personal) and want to:
- Keep them isolated and secure
- Avoid constantly switching SSH keys
- Have a clean workflow
Gity creates separate SSH keys for each account and auto-configures your ~/.ssh/config so you can use different accounts without conflict.
# Build from source
cargo build --release
# Copy binary to PATH
sudo cp target/release/gity /usr/local/bin/gity
chmod +x /usr/local/bin/gity# Add a GitHub account
gity add work github
# Enter your email when prompted
# Add a Codeberg account
gity add mycodeberg codeberg
# Add GitLab
gity add personal gitlabThis will:
- Generate an SSH key:
~/.ssh/id_ed25519_<name> - Update
~/.ssh/configwith the host alias - Show you the public key to add to your git provider
The output shows the public key. Add it to:
- GitHub: https://github.com/settings/keys
- GitLab: https://gitlab.com/-/profile/keys
- Codeberg: https://codeberg.org/user/keys
- Bitbucket: https://bitbucket.org/account/settings/ssh-keys/
gity test workShould show: ✓ Connection successful!
# Instead of:
git clone git@github.com:username/repo.git
# Use the host alias from gity list:
git clone git@github-work:username/repo.git| Command | Description |
|---|---|
gity add <name> <platform> |
Add a new account (platform: github, gitlab, codeberg, bitbucket) |
gity list |
List all accounts with usage instructions |
gity test [name] |
Test SSH connection to verify key is working |
gity remote add |
Interactive: create remote URL for a specific account |
gity remote switch |
Switch existing remote to different account |
gity export |
Export config to JSON (for backup or moving to another PC) |
gity import < file.json |
Import config from file or stdin |
gity remove <name> |
Remove an account (does NOT delete SSH key files) |
# After adding "work" account:
git clone git@github-work:company/project.git# In your repo directory:
git remote set-url origin git@github-personal:yourname/repo.git# On PC 1 - export your setup
gity export > gity-config.json
# Copy SSH keys manually
cp ~/.ssh/id_ed25519_work* /backup/
cp ~/.ssh/id_ed25519_personal* /backup/
# On PC 2 - import config
gity import < gity-config.json
# Copy SSH keys
cp /backup/* ~/.ssh/
chmod 600 ~/.ssh/id_ed25519_*Gity generates an SSH config like this:
Host github-work
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_work
AddKeysToAgent yes
IdentitiesOnly yes
Host codeberg-codeberg
HostName codeberg.org
User git
IdentityFile ~/.ssh/id_ed25519_codeberg
AddKeysToAgent yes
IdentitiesOnly yes
Then you use git@github-work:user/repo instead of git@github.com:user/repo - SSH automatically picks the right key.
- SSH keys are stored in
~/.ssh/with 600 permissions - Each key is isolated per account
- Config file is auto-generated (don't manually edit)
- Use
gity testto verify before pushing
- Rust (to build)
- OpenSSH
- Git
MIT