Stable v1.1.9

🔐 gitswitch

Safe Git identity switching with SSH and GPG isolation

A security-focused tool for managing multiple Git identities. Prevents credential mixing between work and personal accounts through isolated SSH agents and separate GPG environments. Built in C with comprehensive security hardening and support for complex multi-organization workflows.

🎯 RPM Available

Features

Installation

RPM (Fedora/RHEL/CentOS)

terminal
$sudo dnf config-manager --add-repo https://repos.musicsian.com/musicsian.repo
$sudo dnf install gitswitch

Build from Source

terminal
$git clone https://github.com/espadon/gitswitch.git
$cd gitswitch
$make release
$sudo make install

Build Dependencies: gcc, make, openssl-devel

Runtime Dependencies: git, openssh-clients, gnupg2 (optional)

Quick Start

1. Add Your First Account

Run the interactive setup to configure an account with SSH and GPG keys:

terminal
$gitswitch add
Account Setup ───────────── Enter name: John Doe Enter email: john@work.com Enter description (optional): Work account Enable SSH key management? [y/N]: y SSH key path: ~/.ssh/id_ed25519_work SSH host alias (optional): github.com-work Enable GPG signing? [y/N]: y GPG key ID: ABCD1234EFGH5678 ✓ Account 'john@work.com' added successfully

2. Add a Second Account

terminal
$gitswitch add
Account Setup ───────────── Enter name: Johnny Personal Enter email: johnny@gmail.com Enter description (optional): Personal projects Enable SSH key management? [y/N]: y SSH key path: ~/.ssh/id_ed25519_personal SSH host alias (optional): github.com-personal Enable GPG signing? [y/N]: n ✓ Account 'johnny@gmail.com' added successfully

3. Switch Between Accounts

terminal
$gitswitch work
Switching to account: john@work.com ✓ Git config set (local scope) ✓ SSH agent started with key loaded ✓ GPG signing configured Active: John Doe <john@work.com>

4. Verify Current Status

terminal
$gitswitch status
Current Account ─────────────── Name: John Doe Email: john@work.com Scope: local SSH: ✓ Agent running (key loaded) GPG: ✓ Signing enabled (key: ABCD1234EFGH5678)

SSH Host Alias Setup

For multiple GitHub accounts, configure SSH host aliases in ~/.ssh/config:

# Work account
Host github.com-work
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_ed25519_work
    IdentitiesOnly yes

# Personal account
Host github.com-personal
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_ed25519_personal
    IdentitiesOnly yes

Then clone using the alias:

terminal
$git clone git@github.com-work:company/repo.git

Shell Integration

Add to your shell configuration for persistent SSH agent environment:

Bash (~/.bashrc)

# gitswitch SSH agent integration
if [ -S "$HOME/.config/gitswitch-ssh/current.sock" ]; then
    export SSH_AUTH_SOCK="$HOME/.config/gitswitch-ssh/current.sock"
fi

Zsh (~/.zshrc)

# gitswitch SSH agent integration
[[ -S "$HOME/.config/gitswitch-ssh/current.sock" ]] && \
    export SSH_AUTH_SOCK="$HOME/.config/gitswitch-ssh/current.sock"

Fish (~/.config/fish/config.fish)

# gitswitch SSH agent integration
if test -S "$HOME/.config/gitswitch-ssh/current.sock"
    set -gx SSH_AUTH_SOCK "$HOME/.config/gitswitch-ssh/current.sock"
end