Session Ready
Exercise

Commit modified files

Since the previous exercise, we have made some changes and now we want to get a list of the files that have changed.

We will include the list of changed files in our next commit message.

A major advantage of GitPython is that it allows us to programmatically access information on the status of our repositories.

Here, we will use the diff() method to obtain a list of files with changes since the latest commit.

Our code should work regardless of how many or which files have been modified.

For an example of how GitPython can be applied in the real world, take a look at the Gitone Python package.

Instructions
100 XP
  • Use the diff() method to create a list of files changed since the last commit.
  • Include only modified files, those with a change_type equal to "M", in the list.