Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

multigit

A tiny CLI for macOS/Linux that manages multiple git identities and SSH keys, and makes it easy to bind a specific account/key to a specific local repo so push/pull/fetch "just work" with the right credentials.

No dependencies beyond bash, git, and ssh-keygen (all pre-installed on macOS and virtually every Linux distro).

How it works

Each "account" you register (e.g. work, personal, client-x) has its own:

  • full name + email → used for commit authorship
  • SSH key → used for authentication

Running multigit use <name> inside a repo sets, locally to that repo only:

  • user.name / user.email
  • core.sshCommand → pins that repo to the account's specific key with IdentitiesOnly=yes

That means every repo can use a different identity/key automatically, with no global SSH config, no ssh-agent juggling, and no risk of accidentally pushing to a client's repo with your personal key.

Install

Option A — one-liner (recommended)

curl -fsSL https://raw.githubusercontent.com/turbostartdev/multigit/main/install.sh | bash

This downloads multigit, installs it to /usr/local/bin/multigit, and verifies it's on your PATH. It uses sudo to write to /usr/local/bin, so it will prompt for your password once up front (before anything is downloaded) — nothing runs with elevated privileges beyond that single install step.

Option B — manual install

# 1. copy the script onto your PATH
sudo cp multigit /usr/local/bin/multigit
sudo chmod +x /usr/local/bin/multigit

# 2. verify
multigit help

/usr/local/bin is on PATH by default on macOS and virtually every Linux distro, so no shell profile changes are usually needed. If you'd rather install without sudo, copy it to ~/bin instead and make sure that's on your PATH.

Config and generated keys are stored under ~/.multigit/ (override with the MULTIGIT_HOME env var).

SSH-AGENT config

Remove any config that points to your git service provider host on ~/.ssh/config file.

Usage

1. Register an account

multigit add work

You'll be prompted for a full name, email, and either an existing SSH key path or nothing (in which case a new ed25519 key pair is generated for you under ~/.multigit/keys/). At the end it prints the public key — copy it into your git host's SSH key settings (e.g. github.com/settings/keys).

Repeat for as many accounts as you need:

multigit add personal
multigit add client-x

2. Bind an account to a repo

cd ~/code/work-project
multigit use work

This sets local git config so all git network operations in this repo use the work identity and key. Other repos are untouched.

3. Verify SSH auth works

multigit test work

Runs ssh -T git@<host> with that account's key so you can confirm the key is registered with your git host before you try to push anything.

4. Check what a repo is using

multigit current

5. Clone straight into an account

multigit clone personal git@github.com:me/side-project.git

Clones the repo and immediately runs multigit use personal inside it.

6. Push / pull

multigit push origin main
multigit pull

These are thin wrappers around git push/git pull — you can just use git push/git pull directly too, since the key is already wired in via core.sshCommand. The wrappers just warn you if the current repo has no multigit account set yet.

Command reference

Command Description
multigit add <name> Register a new account (interactive)
multigit gen-key <name> Generate a fresh key for an existing account (backs up the old one)
multigit list List all registered accounts
multigit show <name> Show one account's details
multigit remove <name> Remove an account (key files kept on disk)
multigit use <name> Bind an account to the current repo
multigit current Show which account the current repo uses
multigit test <name> Test SSH auth for an account
multigit clone <name> <url> [dir] Clone a repo and bind the account immediately
multigit push [args] git push wrapper
multigit pull [args] git pull wrapper

Notes

  • HTTPS remotes: multigit use only affects SSH-based git operations. If your origin is an https:// URL, the key won't be used — multigit use will warn you about this. Use an SSH remote URL (git@github.com:user/repo.git) to take advantage of per-repo keys.
  • Multiple accounts on the same host (e.g. two GitHub accounts): this works fine because auth is pinned by key file, not by SSH Host alias — you don't need to rewrite remote URLs or maintain ~/.ssh/config entries.
  • Removing an account (multigit remove) only removes it from multigit's registry; it does not delete the key files or touch any repo that already has core.sshCommand set — that repo will just keep working exactly as before until you multigit use a different account there.

About

tiny CLI to avoid ssh-agent juggling when using GIT with multiple identities

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages