Search code examples
pythongitpython-2.7gitpython

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?


Solution

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