git-config-manager
git-config-manager
is a tool for setting git configurations by schemes described
in json
file. It is useful in situations when you can specify different sets of
configurations for different repositories (like work, personal etc) and want to
avoid typing configurations by hand for every single repository.
For example, consider following content in
$XDG_CONFIG_HOME/git/git-config-manager.json
(which is loaded by default if you
donโt override it using --config-file
option).
{
"personal": {
"user": {
"name": "The Donkey",
"email": "[email protected]",
"signingkey": "ABCDEFGH"
}
},
"my_project": {
"pull": {
"rebase": true
}
},
"work": {
"user": {
"name": "Mr. Doe",
"email": "[email protected]",
"signingkey": "ABCDEFGH"
},
"pull": {
"rebase": null
}
}
}
You can navigate to any repository and call git-config-manager set personal
to
set all configurations under personal
scheme.
Note that supported value types are strings, numbers and booleans. If you set
the value to null
, it will be unset (and in case corresponding section is empty
it will be also removed).
Interface
$ git-config-manager --help Git configuration manager Usage: git-config-manager [--verbose] [--config-file PATH] COMMAND Manage git configurations and switch between them with ease Available options: -h,--help Show this help text --verbose Enable verbose mode --config-file PATH Specify configuration file path Available commands: list List all available configuration schemes get Get list of currently used schemes set Set up configurations by scheme unset Unset configurations by scheme
Install
The easiest way to install git-config-manager
is to use stack.
$ git clone https://github.com/d12frosted/git-config-manager.git
$ cd git-config-manager
$ stack install
Magit
interface
Git configuration manager comes with magit
interface. It just adds new section
to status buffer. All available actions are available under C
key. In order to
set configuration scheme selected desired scheme and press C s
. In order to
unset it - C u
.
Install
While package is not available on MELPA, one can install it using quelpa
.
After magit-gcm
is available on your load-path
, just add following snippet
to your init.el
.
(require 'magit-gcm)
(add-hook 'magit-mode-hook 'turn-on-magit-gcm)
Configure
There are several configuration variables available to users.
magit-gcm-exectuable
- by default it searches for executable in PATH. If for some reason it canโt be found or you just wish to manually specify it - set this variable.magit-gcm-config-file
- by default itโsnil
, which means thatmagit-gcm
will not pass configuration file path togit-config-manager
, so the default configuration file will be used. But in some cases it might be useful to manually set this variable.magit-gcm-mode-lighter
- mode line lighter formagit-gcm-mode
.
For convenience, magit-gcm
exposes several utility functions.
magit-gcm-exec
- for executinggit-config-manager
commands.magit-gcm-get-active-schemes
- returns list of currently activated configuration schemes.magit-gcm-get-available-schemes
- returns list of all available configuration schemes.