Worktree & dotgit folder in different locations
You don’t want to put a git repository in a Dropbox/iCloud/GoogleDrive/OneDrive/(WhatEverDrive) synced folder. Git has locked filed, they can’t de synchronized properly and this seriously messes up the repository. Data gets corrupted and, in the end, lost.
But I need it. I want my Obsidian.md notes on iCloud or Dropbox, because I use Obsidian Mobile. At the same time, I want my vault to be on a private GitHub repo.
Here’s the solution.
First, leave your vault in its synced folder, e.g.
Then, setup a git repository in a safe location outside of the scope of the sync services, e.g.
Edit the git configuration file at
~/git/obsidian/.git/config adding a single line with the
worktree keyword and the path to the vault :
worktree = $HOME/Dropbox/obsidian/myvault
Et voilà !