Automatically committing and pushing changes to a repository, as for this collection of raw notes


This presumes you are on Debian, Ubuntu, or other variant.

sudo apt install inotify-tools
mkdir ~/Applications
cd ~/Applications
git clone
ln -s ~/Applications/gitwatch/ ~/.local/bin/gitwatch
echo "#!/usr/bin/env bash

nohup gitwatch -r origin -L 1 /home/mlncn/Projects/agaric/raw-notes/ & disown" > ~/.local/bin/gitwatch-rawnotes
chmod +x ~/.local/bin/gitwatch-rawnotes


I installed as i have before, and am letting it do its thing for my /etc directory, but decided to use a lighter, or at least more general, approach for my notes directory.


I was reminded of both by this concise answer:

/usr/local/bin/gitwatch -r origin -m "Auto-commit on change (%d)" ~/Projects/agaric/resources/raw-notes/

And then i put that into my Startup Applications (which simply takes a command, namely, what i have pasted above).

(The %d just becomes a timestamp.)

I considered trying to make the commit messages better (it’d be awesome if it did that natural language summarizing of the text changes in the file) but held back, didn’t even look at this

$ cat /proc/sys/fs/inotify/max_user_watches 65536

And this can be raised,

We’re putting it all in:

nohup gitwatch -r origin -m "Auto-commit on change (%d)" /home/mlncn/Projects/agaric/resources/raw-notes/ & disown

Realized that while if using git directly, you can always run git log with --stat to see the files that changed, you can’t see this when browsing, say, GitLab’s list of activity, so i lose all my information on what notes i was actually taking, which are in the file name.

… and that turns out to be a lot harder than one would think.

I commented on the closest GitWatch issue:

And my hopes were answered!

Now my full command file looks like this:

#!/usr/bin/env bash

nohup gitwatch -r origin -m -l 1 /home/mlncn/Projects/agaric/raw-notes/ & disown

The command itself, the above contents, is defined at /usr/local/bin/gitwatch-rawnotes

This makes the command, gitwatch-rawnotes, runnable, and it is configured to start in PopOS/Ubuntu/maybe some advanced config thing’s Startup Application Preferences.