Manage multiple git configurations
Inspired by Git-User-Switch.
I've switched to just using includeIf
in my .gitconfig. Honestly, this works a lot better for me than having to constantly switch users via this command.
# this will install the executable `cgu` and `git-change-user`
cargo install change-git-user
# enable only the cli
cargo install --no-default-features --features=cli change-git-user
# enable only prompts
cargo install --no-default-features --features=prompts change-git-user- Switch
user.nameanduser.emailconfig - Assign an optional
user.signingKeyto the config - Give the config a name to remember it by (e.g. "Work" or "Personal")
- Uses
git2to discover a repository and manipulate its config
NOTE You can use cgu and git change-user interchangeably.
# This will spawn prompts to guide you through managing user configurations
cguIf you don't want use use prompts, you can use subcommands instead. The subcommands are:
addselectdeleteview
# view CLI options
cgu --help
# view subcommand help
cgu <subcommand> --help
# Add a config with the name "My Config"
# Defaults to the user.name value ("My Name" in this example) if --name is not passed
cgu add --name "My Config" "My Name" [email protected]
# View all configs
cgu view --all
# Select the new config
cgu select "My Config"
# Delete the new config
cgu delete "My Config"