Git ID Manager
gid is a Git identity manager that helps switch between multiple "profiles"
of Git configurations. gid is non-intrusive, injecting configuration options
on a per-command basis rather than editing local or global Git configurations.
Furthermore, gid is a cross-platform utility that only requires an available
git command in the environment as a dependency.
gid itself is a wrapper around the git command and can be used as a drop-in
replacement. All options and arguments passed to gid will be forwarded to the
git command with the active Git profile's configuration settings prepended.
gid commit -m "This is a commit"An accompanying utility gidc is used to select and manage Git profiles.
Warning Before
gidor its accompanying utilitygidcare used, a configuration file must be created
gid usage requires an existing configuration file in TOML
syntax.
This file must be named gid.toml, and can be placed in one of three locations
(listed in order of priority):
- Any path pointed to by an environment variable
GID_CONFIG - In the same directory as the
gidandgidcbinaries - In the user's configuration directory (on Windows, this is
%USERPROFILE%/.config/gid/gid.toml; elsewhere, it is$HOME/.config/gid/gid.toml)
An example `gid.toml`
active = "profile_name_1" # The current active Git profile, can be set
# automatically with the `gidc set` command
# Not all TOML types are supported, only valid Git values are allowed:
# booleans, integers, colors (string color/attribute name, 0-255, or 24 bit
# RGB hex code as either a single value or in an array), and strings ("yes",
# "off", paths, etc...)
#
# Details found here: https://git-scm.com/docs/git-config
[profile_name_1]
user.name = "my_git_username"
user.email = "[email protected]"
user.signingkey = "my_git_signingkey"
commit.gpgsign = true
tag.gpgsign = true
pull.rebase = false
core.sshCommand = "ssh -i \"$HOME/.ssh/my_ssh_key\""
# Profiles can specify as few or many configuration options as desired
[whatever_other_name]
user.name = "my_git_username_2"
user.email = "[email protected]"
core.sshCommand = "ssh -i \"$HOME/.ssh/id_rsa\""The gidc utility can be used to manage Git profiles in the gid
configuration file. All commands and options can be found in the --help
section of the gidc utility.
gidc --helpAn active Git profile can be selected with the set command.
gidc set <profile_name>Warning The provided profile name must be a valid name in the configuration file
All available profile names in the configuration file can be listed with the
list command. The currently active profile will be marked with a *.
gidc listAny defined profile can be exported to either a repository-local or the global
Git configuration with the export command.
gidc export [-g] [profile_name]The -g flag indicates whether the profile should be exported to the global
Git configuration. If not set, export will work with the local Git
configuration by default.
A profile name can be provided to export to specify which profile should be
used. If not provided, the current active profile will be used by default.
Local or global Git configurations can be imported to an existing or new
profile with the import command.
gidc import [-g] [profile_name]The -g flag indicates whether the global Git configuration should be
imported. If not set, import will work with the local Git configuration by
default.
A profile name can be provided to import to specify which profile should be
used. If not provided, the current active profile will be used by default. A
new profile name can be provided to create a new profile.