Modern CLI tool for managing multiple Git identities with automatic switching
- Git includeIf automation - Set up once, switches automatically by directory
- SSH config with IdentitiesOnly - Proper multi-account SSH key isolation
- PAT (HTTPS) authentication - Personal Access Token support for HTTPS remotes
- Repo setup (
gh) - Auto-configure repo from remote URL and matching profile - Multi-email support - Multiple emails per profile for different contexts
- Auto SSH key management - Platform-specific keychain integration
- Profile import/export - Share configurations across machines
- GPG commit signing - Automatic GPG key management per profile
- Cross-platform - Single binary for macOS, Linux, and Windows
# macOS (Apple Silicon)
curl -L https://github.com/calghar/gas-cli/releases/latest/download/gascli-darwin-arm64 -o gascli
chmod +x gascli
sudo mv gascli /usr/local/bin/
# macOS (Intel)
curl -L https://github.com/calghar/gas-cli/releases/latest/download/gascli-darwin-amd64 -o gascli
chmod +x gascli
sudo mv gascli /usr/local/bin/
# Linux
curl -L https://github.com/calghar/gas-cli/releases/latest/download/gascli-linux-amd64 -o gascli
chmod +x gascli
sudo mv gascli /usr/local/bin/
# Windows (PowerShell)
# Download from https://github.com/calghar/gas-cli/releasesgit clone https://github.com/calghar/gas-cli.git
cd gas-cli
make build
make install # Installs to Go bin ($GOPATH/bin or $GOBIN)go install github.com/calghar/gas-cli@latest# Add profiles (name required; git-name, email, PAT, gpg-key optional)
gascli add work "John Doe" john.doe@company.com ABC123DEF456
gascli add personal john@gmail.com
gascli add work "John Doe" ghp_xxxx # With PAT for HTTPS
# Setup automatic directory-based switching (recommended!)
gascli auto ~/projects/work work
gascli auto ~/projects/personal personal
# Now Git automatically uses the right profile in each directory!
# Or switch manually (affects global git config)
gascli switch work
gascli --auto-ssh switch personal # Also adds SSH key
# Configure repo from remote URL (run from repo root)
gascli gh # Matches profile by GitHub username, sets user.name/email/remote
# List profiles and directory rules
gascli list
gascli auto-list
# View current configuration
gascli current| Command | Description |
|---|---|
gascli add <name> [git-name] [email/pat] [gpg-key] [--pat TOKEN] |
Add a new profile |
gascli auto <dir> <profile> |
Setup automatic switching (uses Git includeIf) |
gascli auto-remove <dir> |
Remove directory rule |
gascli switch <name> [email] |
Manually switch profile globally |
gascli --auto-ssh switch <name> |
Switch and auto-add SSH key to keychain |
gascli gh |
Configure repo from remote URL and matching profile |
gascli list |
List all profiles with details |
gascli current |
Show current Git configuration |
gascli auto-list |
List directory rules |
gascli remove <name> |
Remove a profile |
gascli pat set <profile> <token> |
Set PAT for HTTPS authentication |
gascli pat clear <profile> |
Clear PAT for profile |
gascli add-email <profile> <email> |
Add email to profile |
gascli remove-email <profile> <email> |
Remove email from profile |
gascli export [file] |
Export profiles to JSON |
gascli import <file> |
Import profiles from JSON |
Instead of manually switching profiles, set up automatic directory-based switching:
# One-time setup
gascli auto ~/work work-profile
gascli auto ~/personal personal-profile
# That's it! Git now automatically uses the right profile.
# No need to run gascli switch ever again in these directories.How it works: Creates .gitconfig-{profile} files and adds includeIf directives to your global .gitconfig. Git automatically loads the correct configuration based on your repository location.
# Auto SSH key management with SSH config
$ gascli --auto-ssh switch work
Switched to profile 'work' with email 'john@company.com' and name 'John Doe'
Added SSH config entry for profile 'work'
Use this host in git URLs: git@github.com-work:user/repo.git
Adding SSH key to macOS keychain...
Successfully added SSH key for profile 'work' to keychainWhy host aliases? SSH can't distinguish between multiple keys for the same host. Without aliases, SSH tries keys in order and GitHub accepts whichever matches firstβpotentially authenticating you with the wrong account.
When using --auto-ssh, the tool automatically:
- Creates SSH config entries in
~/.ssh/configwith unique host aliases - Adds SSH keys to the agent (without removing other keys)
- Uses
IdentitiesOnly yesto ensure GitHub uses the correct key per profile
Example SSH config entries created:
Host github.com-work
HostName github.com
User git
IdentityFile ~/.ssh/id_work
IdentitiesOnly yes
Host github.com-personal
HostName github.com
User git
IdentityFile ~/.ssh/id_personal
IdentitiesOnly yes
Using the host aliases in your git repos:
# Clone using profile-specific host
git clone git@github.com-work:company/repo.git
# Update existing repo's remote
git remote set-url origin git@github.com-personal:user/repo.gitThis approach allows multiple GitHub SSH keys to coexist peacefully, with SSH automatically selecting the correct key based on the host alias you use.
Run gascli gh from a repo root to auto-configure it from the remote origin:
cd ~/projects/my-repo
gascli ghScans .git/config for the remote URL, extracts the GitHub username, finds a matching profile (by git-name), and sets user.name, user.email, and the remote URL with PAT for HTTPS. If no profile matches, you'll be prompted to select one.
Runtime Requirements:
- Git 2.23.0+ (for includeIf support)
- SSH (for key-based authentication)
- GPG (optional, for commit signing)
Build Requirements (if building from source):
- Go 1.21+
- Make (optional, but recommended)
- Complete Command Reference - All commands and examples
- Use Cases - Team setups, freelancing, organizations
- Security Features - GPG signing, SSH keys, best practices
- Installation Guide - Platform-specific instructions
- Features - Technical details and architecture
- User Guide - Workflows and best practices
# Build for current platform
make build
# Build for all platforms
make build-all
# Run tests
make test
# Format code
make fmt
# Show all available commands
make helpContributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
git clone https://github.com/calghar/gas-cli.git
cd gas-cli
make deps
make build
./bin/gascli --helpThis project is licensed under the MIT License - see the LICENSE file for details.
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: Complete Docs