how do I emulate read and update git global config file using gitPython?

天涯浪子 提交于 2020-06-02 17:08:20

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!