Git Identity
Overview
Working on many projects usually means many identities, and git's built-in way of handling that is painful. Git Identity is a git extension that manages multiple profiles and the SSH keys behind them, so you never accidentally push with the wrong identity. Create an alias, clone through its key, and pin it to a repository - the tool remembers so you do not have to.
Features
- Manage multiple git user profiles behind short aliases.
- Creates a new alias with a fresh keypair in one command.
- Imports the global git and SSH config as an alias.
- Clones private repositories through an alias's SSH key.
- Pins an alias to a repository so pushes always use the right identity.
- Prints the public SSH key of an alias for easy copy and paste.
Building
The build process is fully integrated with the Go build toolchain. The only requirement is the installation of the go package which includes all of the software's dependencies.
# install go toolchain sudo pacman -S go; # build all supported platform binaries cd /path/to/git-identity; bash build.sh;
Installation
- The program binary has to be installed as
/usr/bin/git-identity. - The
${XDG_CONFIG_HOME}/git-identityfolder is the preferred config folder. - The
${HOME}/.config/git-identityfolder is the first fallback config folder. - The
/home/${USER}/.config/git-identityfolder is the second fallback config folder.
# builds and installs the binary to /usr/bin/git-identity cd /path/to/git-identity; bash install.sh;
Usage
git identity create <alias>creates a new alias with a new keypair.git identity import <alias>imports global git user config as new alias.git identity clone <alias>clones a private repository with SSH key of the specified alias.git identity config <alias>modifies current git repository config to always use specified alias.git identity showprints out available aliases.git identity show-key <alias>prints out the public SSH key for the specified alias.
Usage: Example
cd ~/Software; # import global git/ssh config as new alias git identity import cookiengineer; # clone a repo via an aliases' SSH key git identity clone cookiengineer [email protected]:cookiengineer/private-repository.git ./private-repository; # modify alias usage inside a repo cd ./private-repository; git identity config cookiengineer; git push origin master; # uses another-alias automatically! # create another alias cd ~/Software; git identity create another-alias; # easy copy/paste of public key to web apps git identity show-key another-alias;