List all git commits with GitPython

I get able to do some timeseries evaluation on a git repo with python, my first step is to determine a technique to record the entire git commits in order that I can analyze every one nonetheless I need. The GitPython library made this virtually trivial as soon as I spotted how.

from git import Repo

repo = Repo('.') commits = repo.iter_commits()
Enter fullscreen mode

Exit fullscreen mode

This returns a generator, if you’re iterating over them that is seemingly what you need.

commits
# <generator object Commit._iter_from_process_or_stream at 0x7f3307584510>
Enter fullscreen mode

Exit fullscreen mode

The generator will return git.Commit objects with plenty of details about every commit akin to hexsha, creator, commited_datetime, gpgsig, and
message.

subsequent(commits)
# <git.Commit "d125317892d0fab10a36638a2d23356ba25c5621">
Enter fullscreen mode

Exit fullscreen mode

Add a Comment

Your email address will not be published. Required fields are marked *