Your Git identity manager and automatic profile switcher.
gitego is a command-line tool designed to completely eliminate the risk of committing to a repository with the wrong user identity. It allows you to define separate profiles for work, personal projects, and clients, and then automatically switch between them based on your working directory.
It seamlessly manages your user.name, user.email, SSH keys, and Personal Access Tokens (PATs), acting as a unified and intelligent manager for your Git identity.
user.name, email), your authentication method (ssh-key), and your API token (pat).https:// remotes without conflicting with other system tools.You must have Go (version 1.24+) installed on your system.
go install github.com/bgreenwell/gitego@latest
````
*(Note: Ensure your Go bin directory, typically `~/go/bin`, is in your system’s `PATH`.)*
## One-time setup: Configure Git
After installation, you need to tell Git to use `gitego` as its credential helper. This single command makes `gitego` the source of truth for your HTTPS credentials.
```bash
# Clear any old, conflicting helpers
git config --global credential.helper ""
# Set gitego as the one and only helper, using the required '\!' prefix
git config --global --add credential.helper "!gitego credential"
Here’s a typical workflow for setting up and using gitego.
First, define your different identities.
# A simple personal profile
gitego add personal --name "Brandon" --email "brandon.personal@email.com" --username "bgreenwell-personal"
# A work profile that uses a specific SSH key
gitego add work-ssh --name "Brandon Greenwell" --email "brandon.work@company.com" --username "bgreenwell-work" --ssh-key ~/.ssh/id_work
# A client profile that uses a PAT for HTTPS
gitego add client-abc --name "Brandon G." --email "brandon@client-abc.com" --username "bgreenwell-client" --pat "ghp_YourClientPATHere"
Use the list (or ls) command to see all the profiles you’ve saved.
gitego list
Expected Output:
ACTIVE PROFILE NAME EMAIL ATTRIBUTES
------ ------- ---- ----- ----------
client-abc Brandon G. brandon@client-abc.com [PAT]
personal Brandon brandon.personal@email.com
work-ssh Brandon Greenwell brandon.work@company.com [SSH]
The use command sets your default global identity for any repositories that don’t have a specific rule. This will also update your global .gitconfig.
gitego use personal
Expected Output:
✓ Set active profile to 'personal'.
Now, gitego list will show the active profile marked with an asterisk:
ACTIVE PROFILE NAME EMAIL ATTRIBUTES
------ ------- ---- ----- ----------
client-abc Brandon G. brandon@client-abc.com [PAT]
* personal Brandon brandon.personal@email.com
work-ssh Brandon Greenwell brandon.work@company.com [SSH]
Now, tell gitego which profiles to use for which project directories.
gitego auto ~/dev/work/ work-ssh
gitego auto ~/dev/personal/ personal
When you cd into ~/dev/work/any-repo, your user.name, user.email, and sshCommand will be automatically switched to the work-ssh profile.
gitego solves real-world identity management challenges for developers across various scenarios:
git config switching, accidental wrong commits, security breaches| Command | Alias | Description |
|---|---|---|
gitego add <name> |
Adds a new user profile. | |
gitego rm <name> |
remove |
Removes a saved user profile, asking for confirmation. |
gitego list |
ls |
Lists all saved user profiles and their attributes. |
gitego use <name> |
Sets a profile as the active global default. | |
gitego auto <path> <name> |
Sets a profile to be used automatically for a given directory path. | |
gitego status |
Displays the current effective Git user and the source of the configuration. | |
gitego edit <name> |
Edits an existing user profile's attributes. | |
gitego install-hook |
Installs a pre-commit hook in the current repo to prevent misattributed commits. | |
gitego completion <shell> |
Generates shell completion scripts. | |
gitego --version |
-v |
Prints the application version. |
gitego is built on top of two powerful, native Git features, ensuring it works seamlessly without fighting against Git's own mechanisms.
graph LR
A[Enter Directory] --> B{Auto-rule?};
B -- Yes --> C[Activate Profile .gitconfig];
C --> D[Switch user/email/SSH];
B -- No --> E[Use Global .gitconfig];
D --> F[git push/pull];
E --> F;
F --> G{HTTPS?};
G -- Yes --> H[Git calls gitego helper];
H --> I[gitego finds profile];
I --> J[Get PAT from Keychain];
J --> K[Return credentials];
G -- No --> L[Use sshCommand];
K --> M[Auth OK];
L --> M[Auth OK];
includeIfFor managing your commit identity (user.name, user.email) and SSH keys, gitego uses a Git feature called conditional includes.
When you run gitego auto ~/work work-ssh:
gitego creates a small, dedicated config file at ~/.gitego/profiles/work-ssh.gitconfig.[user] and [core] information for that profile.gitego then adds a block to your main ~/.gitconfig file that looks like this:
ini
[includeIf "gitdir:~/work/"]
path = ~/.gitego/profiles/work-ssh.gitconfigThis tells Git: "if the current repository is inside the ~/work/ directory, merge the settings from this other file." It's a native, fast, and highly reliable way to switch contexts.
For handling Personal Access Tokens (PATs) with HTTPS remotes, gitego acts as a Git credential helper.
git config --global credential.helper '!gitego credential' command tells Git that whenever it needs a username or password for an https:// URL, it should run the gitego credential command.git push or git pull on an HTTPS remote, Git executes gitego credential in the background and pipes it the protocol, host, and path information.gitego credential command uses the same logic as gitego status: it checks the current working directory to find the active profile via auto-rules or the global default.gitego is designed with security as a top priority. Here's how it keeps your credentials safe:
gitego uses the native, secure keychain of your operating system to store and retrieve your PATs. This is the same secure storage that tools like Docker and other credential managers use.By leveraging these native OS features and Git's own robust mechanisms, gitego provides a seamless and secure way to manage your developer identities.
Contributions are welcome! Please feel free to open an issue or submit a pull request.
This project is licensed under the MIT License.
$ claude mcp add git-ego \
-- python -m otcore.mcp_server <graph>