[Python] How to get list of modified files of a Git repo in python?

Discussão em 'Python' iniciado por Stack, Maio 4, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to write a function using python to determine modified files in a git repository. I saw there are couple of packages:


    How can I get a list of pathlib.Path instances of modified files?

    Python version in use: 3.8

    Edit:


    In order to check modified files in GitPython I have tried the following:

    diff = repo.git.diff('HEAD~1..HEAD', name_only=True)


    but this gives me the files that are different, comparing the latest commit with the one before, instead of comparing the latest commit with unstaged changes.

    Continue reading...

Compartilhe esta Página