-
-
Notifications
You must be signed in to change notification settings - Fork 954
Help with git config #1140
-
Hi there,
Maybe it is a newbie question, but is there any method on GitPython that retrieves the configuration at levels system, global and local easily?
I am already using git.config(key) for local configuration, but I would like to know if there is any other way to get at all levels.
I have tried using GitConfigParser, but when I try to get user or user.name, for example, I get the error configparser.NoSectionError: No section: 'user.name'
Could you help me, please?
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions
What should work is to explicitly ask for a ConfigReader at from an existing git repository instance, like so: r = git.Repo(path).config_reader()
. When that instance is asked for a value like so r.get_value('user', 'name')
it would find the respective value in any of the layered configuration files, looking first in the repository configuration, then user, and then the system.
I hope that helps. Please note that I am closing this issue, yet you are free to keep posting here for follow-up questions or comments.
Replies: 1 comment
-
What should work is to explicitly ask for a ConfigReader at from an existing git repository instance, like so: r = git.Repo(path).config_reader()
. When that instance is asked for a value like so r.get_value('user', 'name')
it would find the respective value in any of the layered configuration files, looking first in the repository configuration, then user, and then the system.
I hope that helps. Please note that I am closing this issue, yet you are free to keep posting here for follow-up questions or comments.
Beta Was this translation helpful? Give feedback.