Search code examples
pythonapigitpython

Git python script to extract all the later commits from a given sha commit id


Am trying to use Python to extract the list of all commit messages from a branch after a specific start commit. i couldn't find any useful function from GITPython api or maybe i just missed it. Could anyone please guide me with it?


Solution

  • You may want to try PyDriller, it's easier:

    for commit in RepositoryMining("path_to_repo", from_commit="STARTING COMMIT").traverse_commits():
        print(commit.msg)
    

    If you want commits of a specific branch, add the parameter only_in_branch="BRANCH_NAME". Docs: http://pydriller.readthedocs.io/en/latest/