Skip to main content

Python library to discover commit times of all files under a git repository

Project description

This is a library for finding the commit times of all the files under a git repository.

Can be used from the commandline:

$ cd /some/repository
$ gitmit

Or as a library:

from import GitTimes
print(GitTimes(root_folder, ".").find())

Options to both include:


The relative folder to the root of the repository that we care about. The rest of the filters are then relative to here.


A list of globs specifying what to include (i.e. anything not covered by the globs is ignored)


A list of globs specifying what to exclude after timestamps_for is taken into account


A list of globs specifying what should be re-included after exclude is taken into account


Boolean saying whether we should write the resulting commit times to a file under the .git folder that we can reuse in the future.


Currently the only difference with debug is outputting the commits per second as we traverse the commits in the repository.


I needed this ability in my Docker client ( so that I could maintain the modified times of the files in the context sent to the docker daemon between builds on my build servers (doing a git clone sets the modified times of the files to the time of the clone).

Originally I was shelling out to git log for every file. This was slow! I then moved to dulwich (python implementation of git) which was faster, but still slow. Then I implemented it with pygit2 (libgit2 c bindings in python) and decided to make it a separate library.

Unfortunately it’s still not as fast as doing a git whatchanged --pretty=%at and interpreting the results, but I rather a solution that uses libraries rather than interpreting text from the output of a program and the speed is not a problem for reasonably sized repositories.

In September 2018 I moved back to using dulwich. This is because pygit2 is a bit of a pain because of how it pins to particular versions of libgit2, which itself can be annoying to get installed such that pygit2 can find it.


Just use pip:

$ pip install gitmit


0.5 - TBD
  • Switch to dulwich over pygit2. This is because pygit2 is a pain to install. The downside is it is slower, but only by a few seconds.

Before 0.5 no changelog was maintained


Install testing deps and run the helpful script:

$ pip install -e .
$ pip install -e ".[tests]"
$ ./

Or use tox:

$ pip install tox
$ tox

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gitmit-0.5.tar.gz (11.1 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page