How to get git diff with full context using gitpython


I want to get the changes to a file in a git repository using the gitpython library.
I’m using
repo.git.diff(commit_a, commit_b, file_path)
for that. But I need to increase the context of the diff similar to the -U argument. How can I do this using the library?


I solved it using subprocess at the end, like this:
subprocess.check_output(['git', 'diff', '-U500', commit_a, commit_b, file_path], cwd=project_dir).

Answered By – keheliya

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published