I am looking to get only the diff of a file changed from a git repo. Right now, I am using gitpython to actually get the commit objects and the files of git changes, but I want
I'd suggest you to use PyDriller instead (it uses GitPython internally). Much easier to use:
for commit in RepositoryMining("path_to_repo").traverse_commits():
for modified_file in commit.modifications: # here you have the list of modified files
print(modified_file.diff)
# etc...
You can also analyze a single commit by doing:
for commit in RepositoryMining("path_to_repo", single="123213")