I am trying o grasp gitpython module,
hcommit = repo.head.commit tdiff = hcommit.diff(\'HEAD~1\')
but tdiff = hcommit.diff(\'HEAD^ H
tdiff = hcommit.diff(\'HEAD^ H
For a proper solution (without using git command callback), you have to use create_patch option.
To compare current index with previous commit:
diff_as_patch = repo.index.diff(repo.commit('HEAD~1'), create_patch=True) print(diff_as_patch)