It looks like this (YMMV) if you configure this as your pre-commit hook:
? Please select an email for commit ›
❯ foo@bar.com
baz@example.com
It will ask each time which email you would like to configure before committing.
Your selection will be written to your local .git/config
and used for the current commit.
I admit it's really niche, just imagine you happened to share a local git repository with someone,
you both work on the same files, with the same user, on an airtight (no internet) system,
and you wish to be able to distinguish commit authors.
Sounds awful ? It should.
It could also be useful if you need to contribute with several identities on a regular basis,
from the same local git repository.
It lists emails from the following sources:
- local
.git/config
- global git config (several possible paths)
.git-emails.toml
It then presents a selection menu for choosing the email you wish to use for committing.
Your selection will be written to your local .git/config
and used for the current commit.
Since the default selection is the email from .git/config
, it will remember your last choice:
the last configured email will be the first one in the selection list the next time it runs.
Build using musl
cargo build --target=x86_64-unknown-linux-musl
and then
❯ ldd target/x86_64-unknown-linux-musl/debug/pre-commit-mail-selection
statically linked
- compile it:
cargo build --target=x86_64-unknown-linux-musl --release
- install it
cp target/x86_64-unknown-linux-musl/release/pre-commit-mail-selection .git/hooks/pre-commit
create .git-emails.toml
file inside your git repository:
see .git-emails.toml for an example.
Does not work with IDE that do not run pre-commit hooks in a terminal.