The Problem
You work on multiple projects:
- Work β commits should use
you@company.com
- Personal β commits should use
you@gmail.com
- Open Source β commits should use
you@users.noreply.github.com
You accidentally commit with the wrong email. Your work repo now has personal commits. Your contribution graph is broken. Sound familiar?
The Solution
gitch manages your git identities so you don't have to think about it.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β
β $ gitch use β
β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Select an identity β β
β β β β
β β > π’ work β β
β β you@company.com β β
β β β β
β β π personal β β
β β you@gmail.com β β
β β β β
β β π opensource β β
β β you@users.noreply.github.com β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β
β β Switched to "work" identity β
β β SSH key loaded into agent β
β β GPG signing configured β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β¨ Features
π Identity Management
Create, switch, and manage multiple git identities. Each identity stores name, email, and optional SSH key.
π SSH Key Integration
Generate new SSH keys per identity or link existing ones. Keys auto-load into ssh-agent on switch.
βοΈ GPG Commit Signing
Generate GPG keys or link existing ones. Git commit signing auto-configures on identity switch.
π¨ Beautiful TUI
Interactive setup wizard and identity selector built with Bubble Tea. Terminal UI that sparks joy.
|
β‘ Auto-Switching Rules
Define directory or remote-based rules. Enter ~/work/** β automatically switch to work identity.
π‘οΈ Pre-Commit Protection
Install hooks that prevent wrong-identity commits. Configure per-identity: warn, block, or allow.
π Shell Prompt Integration
See your current identity in your prompt. Ultra-fast (<5ms) cache-based updates for Bash, Zsh, and Fish.
|
π Shell Completions
First-class tab completion for Bash, Zsh, and Fish. Never type a full command again.
|
π Secure by Default
SSH keys stored in ~/.ssh/ with proper permissions. GPG keys in system keyring. No credentials in plain text.
|
π¦ Installation
Homebrew (macOS)
brew install orzazade/tap/gitch
Using Go
go install github.com/orzazade/gitch@latest
From Source
git clone https://github.com/orzazade/gitch.git
cd gitch
make build
π Quick Start
Option 1: Interactive Setup (Recommended)
gitch setup
This launches a beautiful wizard that guides you through creating your first identity.
Option 2: Manual Setup
# Create your first identity with a new SSH key
gitch add --name "work" --email "you@company.com" --generate-ssh
# Create another with an existing SSH key
gitch add --name "personal" --email "you@gmail.com" --ssh-key ~/.ssh/id_personal
# Create identity with GPG signing enabled
gitch add --name "opensource" --email "you@github.com" --generate-gpg
# Or use an existing GPG key
gitch add --name "secure" --email "you@secure.com" --gpg-key ABCD1234EFGH5678
# Switch between them
gitch use work
# Or use the interactive selector
gitch use
π Commands
Core Commands
| Command |
Description |
gitch setup |
π§ Interactive setup wizard |
gitch add |
β Create a new identity (with --generate-ssh, --generate-gpg options) |
gitch list |
π List all identities |
gitch status |
ποΈ Show current active identity (-v for rule details) |
gitch use [name] |
π Switch to an identity (interactive if no name) |
gitch delete <name> |
ποΈ Delete an identity |
Auto-Switching & Hooks
| Command |
Description |
gitch rule add <pattern> --use <identity> |
π Add directory rule (e.g., ~/work/**) |
gitch rule add --remote <pattern> --use <identity> |
π Add remote rule (e.g., github.com/company/*) |
gitch rule list |
π List all switching rules |
gitch rule remove <pattern> |
ποΈ Remove a rule |
gitch hook install |
π‘οΈ Install pre-commit hook globally |
gitch hook uninstall |
β Remove pre-commit hook |
gitch config hook-mode <identity> <mode> |
βοΈ Set hook behavior (warn/block/allow) |
Shell Integration
| Command |
Description |
gitch init <shell> |
π Output shell prompt integration code (bash/zsh/fish) |
gitch completion <shell> |
π Generate shell completions |
π Auto-Switching Rules
Set up rules to automatically switch identities based on directory or remote:
# Switch to "work" when in any subdirectory of ~/work
gitch rule add ~/work/** --use work
# Switch to "opensource" for any github.com/orzazade/* repo
gitch rule add --remote "github.com/orzazade/*" --use opensource
# View all rules
gitch rule list
# Remove a rule
gitch rule remove ~/work/**
π‘οΈ Pre-Commit Hooks
Prevent accidental commits with the wrong identity:
# Install the pre-commit hook globally
gitch hook install
# When you commit with wrong identity, you'll see:
# β Identity mismatch: expected "work", but current is "personal"
# [S]witch to work / [C]ontinue anyway / [A]bort
# Configure per-identity behavior
gitch config hook-mode work block # Always block wrong identity
gitch config hook-mode personal warn # Just warn (default)
gitch config hook-mode oss allow # No checks for this identity
# Bypass when needed
GITCH_BYPASS=1 git commit -m "emergency fix"
π Shell Prompt Integration
See your current git identity right in your prompt:
# Add to your shell config:
eval "$(gitch init zsh)" # For Zsh (~/.zshrc)
eval "$(gitch init bash)" # For Bash (~/.bashrc)
source (gitch init fish) # For Fish (~/.config/fish/config.fish)
# Your prompt will show:
# [work] ~/projects/company $
π Shell Completions
Enable tab completion for your shell:
Bash
# Add to ~/.bashrc
source <(gitch completion bash)
Zsh
# Add to ~/.zshrc (before compinit)
source <(gitch completion zsh)
Fish
gitch completion fish > ~/.config/fish/completions/gitch.fish
βοΈ Configuration
gitch stores configuration in the XDG config directory:
| Platform |
Location |
| Linux/macOS |
~/.config/gitch/config.yaml |
| Windows |
%APPDATA%\gitch\config.yaml |
SSH keys are stored in ~/.ssh/ with the naming convention gitch_<identity-name>.
GPG keys are generated and imported into your system GPG keyring (~/.gnupg/).
πΊοΈ Roadmap
v1.x - Core Features (Complete)
| Phase |
Features |
| β
Foundation |
Core identity management (add, list, status, use, delete) |
| β
SSH Integration |
SSH key generation and ssh-agent integration |
| β
TUI Experience |
Interactive setup wizard, identity selector, shell completions |
| β
Auto-Switching |
Directory/remote rules, pre-commit hooks, bypass support |
| β
Shell Prompt |
Fast prompt integration for Bash, Zsh, and Fish |
| β
Distribution |
Homebrew tap for easy macOS installation |
| β
GPG Signing |
GPG key generation, linking, and auto-configure on switch |
v2.0 - Security & Distribution (In Progress)
| Phase |
Features |
| π§ Import/Export |
YAML export/import for identity backup and migration |
| π§ SSH Config |
Auto-generate SSH config Host aliases per identity |
| π§ Encrypted Backup |
Age-encrypted SSH key export/import |
| π§ Cross-Platform |
Windows (Scoop, Chocolatey, winget) and Linux (APT) |
π€ Contributing
Contributions are welcome! Whether it's bug reports, feature requests, or pull requests.
Please read CONTRIBUTING.md for guidelines.
ποΈ Built With
π License
MIT License - see LICENSE for details.