gitch

command module
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2026 License: MIT Imports: 2 Imported by: 0

README ΒΆ

gitch logo

gitch

Never commit with the wrong git identity again.

CI Release Go Version Go Report Card License

A beautiful CLI for managing multiple git identities with SSH keys, GPG signing, auto-switching rules, and shell prompt integration.

Installation Β· Quick Start Β· Features Β· Commands Β· Contributing


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

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

Cobra Viper Bubble Tea Lipgloss


πŸ“„ License

MIT License - see LICENSE for details.


Stop context-switching. Start committing with confidence.


Made with ❀️ by Orkhan Rzazade


⭐ Star this repo Β· πŸ› Report Bug Β· πŸ’‘ Request Feature

Documentation ΒΆ

The Go Gopher

There is no documentation for this package.

Directories ΒΆ

Path Synopsis
internal
git
Package git provides an adapter for reading and writing git configuration.
Package git provides an adapter for reading and writing git configuration.
gpg
Package gpg provides GPG key generation, validation, and management utilities.
Package gpg provides GPG key generation, validation, and management utilities.
hooks
Package hooks provides pre-commit hook installation and management
Package hooks provides pre-commit hook installation and management
ssh
Package ssh provides SSH key generation, validation, and path utilities.
Package ssh provides SSH key generation, validation, and path utilities.
ui
Package ui provides styled terminal output using lipgloss.
Package ui provides styled terminal output using lipgloss.
ui/selector
Package selector provides an interactive identity selector TUI.
Package selector provides an interactive identity selector TUI.
ui/wizard
Package wizard provides an interactive setup wizard for creating identities.
Package wizard provides an interactive setup wizard for creating identities.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL