且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用gitPython模拟读取和更新git全局配置文件?

更新时间:2022-12-06 17:36:57

这将为您提供〜/.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