I am trying o grasp gitpython module,
hcommit = repo.head.commit
tdiff = hcommit.diff(\'HEAD~1\')
but tdiff = hcommit.diff(\'HEAD^ H
Sorry to dig up an old thread... If you need to find out which files changed, you can use the .a_path or .b_path attribute of a diff object depending on which one you feed it first. In the example below I'm using the head commit as a so I look at a.
e.g:
# this will compare the most recent commit to the one prior to find out what changed.
from git import repo
repo = git.Repo("path/to/.git directory")
repoDiffs = repo.head.commit.diff('HEAD~1')
for item in repoDiffs:
print(item.a_path)