Here is a new usage pattern I came up with recently. An Obsidian vault with folders like this, one per project:
blog/ # jekyll blog hosted on github-pages
game/ # web game project
Now what’s significant about the folders is they are each separate Git projects. So the structure in more detail looks like this:
blog/
+--.git/
+--_drafts/
+--posts/
+--README.md
+--(etc)
game/ # web game project
+--.git/
+--physics/
+--assets/
+--README.md
+--(etc)
So each folder has its own regular .git/ sub-folder as well as the usual project files. You could back this Obsidian project by Obsidian Sync or any other cloud service. You could also keep it standalone if you want to. That’s all beside the point. Why would you do this? The pattern is useful if you want to edit files in Obsidian, with all of its wonderful UI and sync capabilities, but also need to back projects by Git. I find Obsidian especially powerful on mobile. Even a programming project needs documentation that can be composed on a phone when necessary, e.g. you might wish to add some spontaneous ideas to ROADMAP.md on a whim. There’s several scenarios where it’s nice to back such a project by Git instead of - or in addition to - a cloud solution such as Obsidian Sync or iCloud. For example:
- You want to trigger a worker to process your project upon each commit, e.g. to run automated tests, send an email, whatever. In my case, I rely on Github workers to post Jekyll blog updates to Github Pages. You could rig something up to do this every time a file changes, but it would be overkill … in some cases, you really want to do a manual commit. Furthermore, you get much more fine-grained control, e.g. can run the worker only if a commit occurs on a particular branch.
- You want to track changes over time in a more structured way than any time the file changes, i.e. create an audit history with manual commits, comments, branches, tags. This gives you a more powerful audit trail and helps others - and future you - understand how certain decisions were made.
- You are collaborating with other people via Git, They may not have even heard of Obsidian. Everyone gets to choose their own editor, but are connected by a common Git project in the cloud.
Why host several git projects in the same vault instead of just one? Well, you could do just one, but I prefer to host several since Obsidian Sync plans are very limited by number of vaults on offer. It’s also potentially useful to co-mingle projects in the same vault if they are related to each other. I previously tried using only Git as a cloud store for my Jekyll blog, but I found it tedious as I had to keep committing, pushing, and pulling to keep devices in sync as I worked on a specific post. This is especially painful on iPhone, where there’s not really a practical plugin to do this within Obsidian, so you have to keep resorting to a third-party Git app such as Working Copy (which is nevertheless a great tool, for what it’s worth). With the solution above, I can easily switch between devices and everything is “just synced” and stored safely in the cloud. Then, when I’m ready to actually publish an article, I do an official Git commit and push from any device. One downside is the risk of sync conflicts. It could be a problem if a Git command is issued while Obsidian Sync is running. However, I think this is a low-level risk and a good precaution might be to wait a few seconds after saving before issuing any Git push command. I’m still testing this pattern though, so I’ll watch out for any issues.