Manage multiple Git identities on a single machine — personal, work, or anything else.
Janus uses three native mechanisms that Git and SSH already support — it just wires them together for you automatically:
| Mechanism | What it does |
|---|---|
~/.janus/<profile>.gitconfig |
Stores the name + email for each profile |
~/.gitconfig [includeIf "gitdir:..."] |
Auto-applies the right identity based on which folder you're in |
~/.ssh/config Host block |
Routes SSH auth to the correct key per profile |
# Install globally from npm
npm install -g git-janusThe CLI command is janus:
janus --helpOr run from source:
git clone https://github.com/dev-juri/git-janus.git
cd git-janus
npm install
npm run build
npm link # makes `janus` available globallyDuring development, use npm run dev -- instead of janus:
npm run dev -- add
npm run dev -- listjanus addYou'll be walked through:
- Profile name (e.g.
work) - Your full name and email for commits
- Git host (
github.com,gitlab.comorbitbucket.org) - Project folder — where your repos for this profile will live
- SSH key — auto-generate a new Ed25519 key, or point to an existing one
At the end, Janus will:
- Create the project folder if it doesn't exist
- Write
~/.janus/work.gitconfigwith your name, email, and URL rewrite rule - Append an
[includeIf]block to~/.gitconfig - Append a
Hostblock to~/.ssh/config
If a new SSH key was generated, the public key is shown and you can open your Git host's SSH key settings page directly from the prompt.
You can also pre-fill the project folder path as a flag:
janus add --dir ~/workAny repo cloned under the profile's project folder will automatically use that profile's identity:
cd ~/work
janus clone <repo url> # uses work SSH key + work identity automaticallyInteractive wizard to create a new profile. Automates:
- Project folder creation
- SSH key generation (or import of existing key)
~/.gitconfigpatching ([includeIf]block)~/.ssh/configpatching (Hostalias block)
Janus routes SSH auth through a per-profile alias (e.g. git@janus-work:) rather than bare git@github.com:. The URL rewrite that maps one to the other only kicks in once you're inside an existing repo — it can't apply during a fresh git clone because there's no .git directory yet for Git to match against. Without this command, you'd have to manually append -{profile} to every clone URL:
# without janus clone — error-prone every time
git clone git@github.com-work:org/repo.gitjanus clone handles the substitution for you, so you keep using plain URLs:
cd ~/work
janus clone git@github.com:org/repo.git # standard SSH URL
janus clone https://github.com/org/repo.git # HTTPS — converted to SSH automatically
janus clone org/repo # shorthand
janus clone git@github.com:org/repo.git ~/dest # custom destinationProfile is detected from the current directory, falling back to the last janus use selection. Any extra flags are passed directly to git clone (--depth, --branch, etc.).
cd ~/work
janus clone git@github.com:org/repo.git # standard SSH URL
janus clone https://github.com/org/repo.git # HTTPS — converted to SSH automatically
janus clone org/repo # shorthand
janus clone git@github.com:org/repo.git ~/dest # custom destinationAny extra flags are passed directly to git clone (--depth, --branch, etc.).
Manually sets a profile as the global Git identity fallback — affects all directories that don't have a matching [includeIf] block.
janus use workJanus saves your current identity before overwriting it, so you can restore it with
janus reset.
Sets the identity for the current repository only — writes to .git/config. Useful when a repo lives outside its profile's normal folder.
cd ~/some-other-place/work-repo
janus use work --localThis overrides everything — even [includeIf] blocks.
Restores the global identity to what it was before the last janus use call.
janus use work # switches to work
# ... do work ...
janus reset # restores previous identity exactlyIf there's no snapshot (i.e. janus use was never run), janus reset fully unsets user.name and user.email from the global config, so Git falls back to whatever was in ~/.gitconfig before Janus was involved.
Shows all profiles in a table, with the currently active one highlighted.
janus list
# Profile Email Project Dir
# --------------------------------------------------------------------------------------
# ● work jane@acme.com /Users/jane/work/
# personal jane@personal.com /Users/jane/personalShows the effective Git identity in your current directory — and tells you whether it came from a folder match ([includeIf]) or the global fallback.
janus status
# Directory /Users/jane/work/acme/some-repo
# Identity Jane Doe <jane@acme.com>
# Profile work [folder-matched ✓]
# Global Jane <jane@personal.com> [personal]Removes a profile after confirmation. Cleans up:
- The
Hostblock in~/.ssh/config - The
[includeIf]block in~/.gitconfig - The
~/.janus/<profile>.gitconfigfile
Your project folder is never deleted.
When running janus add, choose "I already have a key — enter path" when prompted for SSH key setup. Janus will reference your existing key without moving or modifying it.
To import multiple existing identities, run janus add once per profile and point each to its respective key file.
If you manage your personal identity through your default ~/.gitconfig (without adding it as a Janus profile), you don't need to do anything special. Janus only appends [includeIf] blocks — it never overwrites your existing [user] section.
The recommended setup for this case:
janus add # add work profile only
# personal identity stays as-is in ~/.gitconfigIf you ever need to temporarily work globally under a different identity:
janus use work # overrides global; saves your personal identity first
# ... do work ...
janus reset # restores personal identity exactlyWorks on macOS and Windows (Windows 10+ with OpenSSH). Uses os.homedir() for all path resolution so home directories are always correct regardless of platform.