Crates.io | setgitconfig-rs |
lib.rs | setgitconfig-rs |
version | 0.4.0 |
source | src |
created_at | 2019-08-18 15:37:31.207259 |
updated_at | 2021-09-22 20:17:40.265821 |
description | Set proper git username and email based on the current repository you are in. |
homepage | https://github.com/ansrivas/setgitconfig-rs |
repository | https://github.com/ansrivas/setgitconfig-rs |
max_upload_size | |
id | 157892 |
size | 34,569 |
Sets correct username and useremail for your git-url based on a configuration file.
We work on several repositories from different version control providers. Sometime our username and emails are different and we need to set the git config for each of them otherwise the repositories do not detect it.
This binary solves exactly that, based on a simple toml file.
Install the binary using
cargo install setgitconfig-rs
PROMPT_COMMAND="~/.cargo/bin/setgitconfig; $PROMPT_COMMAND"
chmod +x setgitconfig
sudo mv setgitconfig /usr/local/bin/setgitconfig
~/.bashrc
PROMPT_COMMAND="/usr/local/bin/setgitconfig; $PROMPT_COMMAND"
Just create a directory in your user's home
mkdir -p ~/.config/setgitconfig
Create a file like this:
touch ~/.config/setgitconfig/config.toml
Content of the file can look like this
$ cat ~/.config/setgitconfig/config.toml
[[repositories]]
username= "Ankur Srivastava"
email = "myuser@xmail.com"
giturl = "github.com"
[[repositories]]
username= "Ankur Srivastava"
email = "myuserfor-github@xmail.com"
giturl = "gitlab.com"
In case the binary is not working as expected, simply run the following:
RUST_LOG=debug path/to/setgitconfig