nightshade has written a Python 3 script to automatically commit new changes at a git repository. It requires asyncio, pyinotify and an up-to-date .gitignore file if not all files are to be tracked.

opit has been using it to prevent Texmaker accidentally destroying her LaTeX documents upon crash. Source here.