GitPython

We can use the GitPython package, https://gitpython.readthedocs.io/en/stable/index.html, to work with our Git repository. We will install the package and use the Python shell to construct a Repo object. From there, we can list all the commits in the repository:

$ sudo pip3 install gitpython$ python3>>> from git import Repo>>> repo = Repo('/home/echou/Master_Python_Networking_second_edition/Chapter11/TestRepo')>>> for commits in list(repo.iter_commits('master')):... print(commits)...0aa362a47782e7714ca946ba852f395083116ce5a001b816bb75c63237cbc93067dffcc573c05aa2bc078a97e41d1614c1ba1f81f72acbcd95c0728c2ec5f7d1a734b2cc74343ce45075917b79cc7293c98373069f27d8b98d1ddacffe51b8fa7a30cf28a3dd3ea8e6eb15b57d1f390ce0d2c3a03f07a0385f579ab1e9a3fae13aa7f1b8092055213157524d ...

Get Mastering Python Networking - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.