如何使用gitPython模拟读取和更新git全局配置文件? [英] how do I emulate read and update git global config file using gitPython?

查看:271
本文介绍了如何使用gitPython模拟读取和更新git全局配置文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用git config --list读取git全局配置文件,因此可以用来读取和更新全局配置文件?

I want to reads git global config file using git config --list, so I can use to read and update the global config file ?

推荐答案

这将为您提供〜/.gitconfig类型的config:

This will give you the ~/.gitconfig type config:

 globalconfig = git.GitConfigParser([os.path.normpath(os.path.expanduser("~/.gitconfig"))], read_only=True)

这差不多是gitpython本身所做的,除了它还使用了"system"和"repo"级别的配置(其中系统是"/etc/gitconfig"),请参见

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):

def config_reader(self, config_level=None):

在git/base.py的gitpython源码中

in git/base.py in the source of gitpython

这篇关于如何使用gitPython模拟读取和更新git全局配置文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆