Automatically committing and pushing changes to a repository, as for this collection of raw notes
Quickstart
This presumes you are on Debian, Ubuntu, or other variant.
sudo apt install inotify-tools
mkdir ~/Applications
cd ~/Applications
git clone https://github.com/gitwatch/gitwatch.git
ln -s ~/Applications/gitwatch/gitwatch.sh ~/.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
Background
I installed http://etckeeper.branchable.com/ 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.
Namely, https://github.com/gitwatch/gitwatch
I was reminded of both by this concise answer: https://stackoverflow.com/a/28515756/1028376
/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 https://stackoverflow.com/questions/35010953/how-to-automatically-generate-commit-message#35027514
$ cat /proc/sys/fs/inotify/max_user_watches 65536
And this can be raised, https://unix.stackexchange.com/questions/13751/kernel-inotify-watch-limit-reached#13757
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:
https://github.com/gitwatch/gitwatch/issues/5#issuecomment-445501323
And my hopes were answered! https://github.com/gitwatch/gitwatch/issues/5#issuecomment-450539424
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.