vydd.space/2022/08/git

Git

Ordering posts is weird. I've decided to look at each step as a thread of events in asceding chronological order, but order the steps in reverse. This way, the newest part of the migration story is always at the top, while its contents can be read in order as if dates weren't there.

With the old blog, I didn't like how I had to use git to create posts. Each time I made a commit, I had to wait a considerable amount of time for the git hook that triggered static site generation to complete. It felt worse than compiling code. What I'm doing right now however is instantaneous, and ideally it will stay that way. Here's what I have in mind:

  1. I will keep adding content directly on the server.
  2. There will be a job that watches for changes in the directory. If there are any, it will commit to the local git repository.
  3. To make backups, I'll have the job push to a remote - github for example.
  4. In the hopefully not too far future, I'm going to make an entry mechanism for types of content I'm working with often, and have that replace my manual HTML work.
  5. This will also enable adding content from devices such as my smartphone - or other people's computers.

I didn't know that magit works well with TRAMP! By well I mean that it - just works. I've cloned the repo to my computer, and now I have backups. Onwards to monitoring the repo for changes.

I correctly guessed that git should have an option to return a non-zero exit code when there are uncommitted changes in the repo. I'll try using a simple cron job to look at that exit code and commit if needed. That's actually silly. I can just make the script git commit -C my-directory -a -m "automatic update" whenever it runs.

I've added a line in my crontab to do this. Hopefully, after I save this now, the commit will happen automatically.

          
            * * * * * git -C /home/vydd/www/vydd.space commit -a -m "automatic update"
          
        

I don't think there's 'any benefit to actually monitoring the files. UPDATE It's working!

With a (private) github repo up in addition to the local one, I think I can stop worrying about losing all this work. I just need to make sure I synchronize both remotes regularly.