Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

So here's my little script that automatically commits the content directory to git on changes:

    interval_in_seconds=0.5
    previous=""
    while true; 
    do 
        x=$(ls -R -al ./content | md5); 
        if [[ "$x" != "$previous" ]]; then
            previous=$x
            git add *
            git commit -m "Content update"
            # ...
        fi; 
        sleep $interval_in_seconds; 
    done
Of course it lacks a lot of the functionality that GitJournal has. It is just meant to keep a history of changes.


I started https://GitHub.com/GitJournal/git-auto-sync to do this exact thing. Just with an easier interface and proper tests.

You can basically call `git-auto-sync daemon add`, and it will register itself as a systemd user process (on Linux, other OSs are also supported), and monitor that folder for changes + poll every x minutes.

It's still in the early stages, but I'd love to get your feedback.

Edit: Or you can just call `git-auto-sync sync` to commit + pull / rebase + push.


Consider updating your script to use Entr. It's specifically designed to efficiently and rapidly run code on file changes.

More info from National Treasure Julia Evans: https://jvns.ca/blog/2020/06/28/entr/

Something like this:

    git ls-files | entr autocommit.sh


I have something very similar to this with keybase e2e encrypted git and just triggered by a big button (on laptop/phone).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: