Skip to content

Help with git config #966

Description

@victoraugustofd

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.

Activity

Byron commented on Dec 29, 2019

@Byron
Member

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.

reopened this on Feb 26, 2021
locked and limited conversation to collaborators on Feb 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions