问题
I want to reads git global config file using git config --list
, so I can use to read and update the global config file ?
回答1:
This will give you the ~/.gitconfig type config:
globalconfig = git.GitConfigParser([os.path.normpath(os.path.expanduser("~/.gitconfig"))], read_only=True)
That's more or less what gitpython itself does, except it also uses "system" and "repo" level configs (where system is "/etc/gitconfig"), see
def _get_config_path(self, config_level):
and
def config_reader(self, config_level=None):
in git/base.py in the source of gitpython
回答2:
gitconfig may be exactly what you need.
来源:https://stackoverflow.com/questions/22048996/how-do-i-emulate-read-and-update-git-global-config-file-using-gitpython