← notes

Twenty lines of shell that sync a notes repo and never shout about it

May 10, 2026

Keep a notes repo in sync across machines on a timer, and never interrupt me about it.

sync.sh is about twenty lines. Stage everything, commit only if the index is dirty, fetch, rebase, push only if ahead. On a rebase conflict it aborts the rebase and exits 0.

Exiting 0 on failure is wrong almost everywhere and right here. A conflict means two machines wrote the same file, which is rare. A non-zero exit surfaces an error during whatever I was doing, and the fix is to open the repo and resolve it, which is not going to happen right then. The next run retries anyway. The accepted failure is that a conflict silently parks changes on one machine until noticed, which is fine for notes and would be data loss with a green light on anything where the local copy is the only copy.

git diff --cached --quiet as the dirty check is what stops the repo filling with empty “Save” commits.

Which is the timer doing its job.

Inferred: the reasoning for exit 0 is mine. The script does it; nothing explains why.