The original script I wrote for this is git-account-switcher.sh
. It is bad; it only works for two accounts and requires setting environment variables.
- Implement
help
,add
,remove
,switch
. - Figure out how to store usernames, key locations. Probably a config file.
- Figure out how to check current git account. Probably with SSH key parsing (like the script does).
So far this is only targeting Github accounts via SSH. Other providers and HTTPS will come later.
To build/install: make
Fun fact: any executable in your PATH named git-<command>
is automatically retrieved by git
so you can run it as a subcommand: git <command>
.
git-myCommand
->git myCommand
git-doMagic.sh
->git doMagic
- And so on.
In this case, this repo is named git-account-switcher
, but the command is git-account
, so you would run it as: git account
.
Basic usage: git account help
Subcommands:
git account init {name}
- Initialize the tool with the currently active git account and name it
{name}
. - Not required to run, but convenient.
- Initialize the tool with the currently active git account and name it
git account list
- Returns a list of all accounts registered with the tool.
git account add {name}
- Add a new account and name it
{name}
.
- Add a new account and name it
git account remove {name}
- Remove the account with the name of
{name}
.
- Remove the account with the name of
git account switch {name}
- Switch to the registered account with the name of
{name}
.
- Switch to the registered account with the name of
init
, add
, and switch
will fail if the given name is already regisetered.
remove
will fail if the given name is not already registered.