Search code examples
gitpython

How to get the user.email config using gitpython ?


I have a repo initialized as

r = git.Repo.init(dirPath)

How can I get the user.email field for the git config for that repo using gitpython?


Solution

  • After looking into the source of gitpython this is one way I managed to do it.

    r = git.Repo.init(dirPath)
    reader = r.config_reader()
    field = reader.get_value("user","email")