Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Help with git config #1140

Answered by Byron
victoraugustofd asked this question in Q&A
Discussion options

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.

You must be logged in to vote

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

Comment options

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.

You must be logged in to vote
0 replies
Answer selected by Byron
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
Converted from issue

This discussion was converted from issue #966 on February 26, 2021 11:18.

AltStyle によって変換されたページ (->オリジナル) /