Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitPython: Determine files that were deleted in a specific commit

Using gitpython, I am trying to get a list of changed paths; that is, of all the added, changed and deleted files.

I can retrieve the changed and added files from the commit:

  • checkout commit 'X'
  • traverse repo.tree() and collect all the blobs' abspath

If a file was deleted in a specific commit, it will not show up in the tree anymore. How can I get the names of all the deleted files?

like image 743
Wilbert Avatar asked Dec 20 '25 15:12

Wilbert


1 Answers

You can look at the commit's parents and compare the contents of the two (or more, depending on the number of parents) trees.

like image 193
djc Avatar answered Dec 23 '25 07:12

djc



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!