Ever find that managing multiple git identities is a pain? This git transport attempts to make it less painful.
- Git 2.13 or later.
- GNU bash
- awk (BSD or GNU awk recommended)
- sed (BSD or GNU sed recommended)
- openssh client with ssh-agent
bash, awk, sed, and openssh are available by default on Mac OS X, BSD, and most flavors of GNU/Linux. Git likely needs to be installed. On Mac OS X, installing Git through homebrew is recommended.
Add git-idm
script to your $PATH
and make it executable. Then, you can
access the script via git idm
. See git idm help
for usage.
Remove all data stored in $HOME/.gitconfig
related to git idm
. This will
not affect settings used by git.
git idm uninstall
Add your first identity.
git idm add jcool --name "Joe Cool" --email joe@example.com --key ~/.ssh/id_rsa
Activate your identity.
git idm use jcool
Show which identity is active.
git idm active
List all known identities.
git idm list
For more commands see git idm help
.
You can configure your Git identities to automatically switch depending on what
directory you have cloned. For example, let's say you have personal projects
and work projects on the same laptop. Assuming you have a work
identity and a
personal
identity configured, the following commands would help you
auto-switch identites for repositories under designated paths.
git idm track work --directory ~/git/work
git idm track personal --directory ~/git/github
You can list what directories are tracked by a given identity.
git idm list work --tracked
Which will return output like the following.
work identity will automatically apply to the following directories:
/home/user/git/work/
Verify the identity has switched with git config user.email
.
cd ~/git/work
mkdir example
cd example/
git init
# the email identity should show your work email
git config user.email