Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

d12frosted/git-config-manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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": "mybossdontknowme@protonmail.ch",
      "signingkey": "ABCDEFGH"
    }
  },
  "my_project": {
    "pull": {
      "rebase": true
    }
  },
  "work": {
    "user": {
      "name": "Mr. Doe",
      "email": "slave012345@corp.me",
      "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’s nil, which means that magit-gcm will not pass configuration file path to git-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 for magit-gcm-mode.

For convenience, magit-gcm exposes several utility functions.

  • magit-gcm-exec - for executing git-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.

About

Manage git repository configurations with ease

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published