September 14, 2021    Share on: Twitter | Facebook | HackerNews | Reddit

Git autocommit on file changes

Motivation: I wanted to track history of the changes introduced in my notes folder. Didn’t want to create commit, redact commit message after each change because, typically during the day I made multiple edits in notes ad prefer to minimize time spent on managing my notes. I’m quickly jumping into the notes, adding something to existing notes or creating new. Remebering to commit each change is too much overhead for me. I started to look for the solution that will monitor my notes folder, and, if anything changed, create commmit. I found several solutions that serves for that purpose.

For reference see: making-git-auto-commit on StackOverflow.

My choice was gitwatch used as systemd service.

gitwatch # github: ★1k, active

A bash script to watch a file or folder and commit changes to a git repo

Justification: - active with large community - There is an AUR package for Archlinux - does exactly what I want, nothing more - can be used as daemon that starts on boot

Usage:
gitwatch [-s <secs>] [-d <fmt>] [-r <remote> [-b <branch>]]
          [-m <msg>] [-l|-L <lines>] <target>

gwatch github: ★22, low activity

A program that watches a folder for file modifications and commits them to a git repository automatically

After gwatch is started it will watch a given folder and all of its subfolders (recursively) for changes. If a change occurs, a timer will be started (30s by default). After the timer expires, gwatch will create a new git commit with all the modifications. The timer is to prevent creating too many commits when there are a lot of modifications. In order for gwatch to successfully create commits, a git repository must be initialized in the watched folder.

etckeeper

NOTE: I don’t need track permissions

etckeeper is a collection of tools to let /etc be stored in a git, mercurial, darcs, or bzr repository. It hooks into apt (and other package managers including yum and pacman-g2) to automatically commit changes made to /etc during package upgrades. It tracks file metadata that revison control systems do not normally support, but that is important for /etc, such as the permissions of /etc/shadow. It’s quite modular and configurable, while also being simple to use if you understand the basics of working with revision control.

etckeeper now has a website at http://etckeeper.branchable.com/.

git-etc github: ★4, low activity, created 9 years ago, last commit in 2014

Simple daemon that automatically creates git repository in the given directory and creates commit at the specified time interval.

Has GUI, has AUR package

Git Powercommit

Commit every changed submodule Commit every changed regular file or folder, aggregating the files that share a folder into a single commit.

git-wip

git-wip is a script that will manage Work In Progress (or WIP) branches. WIP branches are mostly throw away but identify points of development between commits. The intent is to tie this script into your editor so that each time you save your file, the git-wip script captures that state in git. git-wip also helps you return back to a previous state of development.

inotify

This program is an “inotify cron” system. It consists of a daemon and a table manipulator. You can use it a similar way as the regular cron. The difference is that the inotify cron handles filesystem events rather than time periods.

watchman

Watchman exists to watch files and record when they change. It can also trigger actions (such as rebuilding assets) when matching files change

inotify.sh

This script uses inotifywatch to monitor files status and trigger commands. I designed this for Ansible playbook but you can use this on other development purposes. To install .eg apt-get install -y inotify-tools https://gist.github.com/darencard/5d42319abcb6ec32bebf6a00ecf99e86