| Crates.io | g-rs |
| lib.rs | g-rs |
| version | 2.0.2 |
| created_at | 2024-07-23 00:24:16.777459+00 |
| updated_at | 2024-09-12 08:35:29.612809+00 |
| description | cli tool for managing multiple git profiles |
| homepage | |
| repository | https://github.com/jakublaba/g |
| max_upload_size | |
| id | 1312263 |
| size | 102,180 |
Don't you hate it when you're interacting with multiple git accounts, forget about it and end up making commits with
wrong name?
g is here to solve that issue, without cumbersome management of custom hosts in your ~/.ssh/config and switching your
credentials manually each time.
cargo install g-rs
Warning: Windows is currently not supported.
To get started, you'll need to create your first profile.
g profile add johnsmith "John Smith" john.smith@example.com
By default, g looks if the profile file exists - skipping this stage if it does.
Duplicating profile name is not allowed, using the same username + email combination for 2 different profiles is also not allowed.
Then g generates ssh keys - if none exist, they're both generated; if private exists, public is re-generated from it.
You can also run this command with --force flag to overwrite profile if it exists and re-generate ssh keys.
You can list all existing g profiles with g profile list.
To see properties of a specific profile, use g profile show <PROFILE_NAME>.
The core feature of g is quickly jumping between your profiles. You can do it with the su command: g su johnsmith.
This configures your credentials for current git repository if you run g from inside a repo, or globally otherwise.
You can still set profile globally from inside a repo by using the --global flag.
Even though su is also related to profile management, I've decided to put it as a separate command rather than
subcommand of profile, because of how often it is used.
You can see currently active profile with g whoami, it also supports --global flag to check the globally configured
profile.
This is just basic overview of commands, for more info run the built-in g help, or help for a specific
command/subcommand.
Switching profiles doesn't do anything fancy - it just finds the correct git config and sets user.name, user.email
and core.sshCommand there.
Your profiles are serialized to bytes and saved under ~/.config/g-profiles/.
Ssh keys are stored in the standard location - ~/.ssh. \
When using whoami command, g infers your identity from user.name and user.email set in detected git config.
In order to avoid scanning all profiles for that, g caches a small key-value store in ~/.config/g-profiles/.cache.
When you remove a profile, it's also wiped from this cache.