Can I sync with Obsidian Git and GitHub if my Obsidian Vault is a Subfolder in the Repo?

What I’m trying to do

Hello,

My current setup is that I have a Vault in my iCloud drive and that syncs between my Macbook and my iPhone, however, I also have a work Windows PC which cannot use the iCloud drive.

I would like to sync my Obsidian Vault using GitHub and the Obsidian Git plugin to be able to also use Obsidian on my Windows PC.

I have turned the Obsidian Documents folder in iCloud into a GitHub repository and it successfully syncs everything there, including my vault folder, however, currently the syncing is done manually through a simple script.

Now, I want to setup syncing with the Obsidian Git plugin. However, the Git plugin assumes by default that your Vault is its own repository in GitHub.

My question is if the Git plugin can be configured in such a way that it will sync the entire repository folder, which is the folder above my vault folder, and not just my Vault?

I see that in the Git Plugin there are some settings for Custom Base Path and Custom Git directory path, but I am not sure which one I should use and what the path should be there.

My Git repository path is:
/Users/kalintri/Library/Mobile Documents/iCloud~md~obsidian/Documents
That is where my .git file is.

And my Vault is a subfolder with path:
/Users/kalintri/Library/Mobile Documents/iCloud~md~obsidian/Documents/My Second Brain

If the Git plugin could be configured, I would like to know how to configure it for
A) sync the entire repository
and
B) Only sync the My Second Brain vault folder in the Repository

I am quite new in using both Git and Obsidian so I would appreciate any help.

Thank you.

Things I have tried

I have only setup my Git folder and manual sync so far.

Wherever the .git (hidden) folder sits that’s a repository. Whatever is beside that folder is included in the repository.

What makes sense: one repo = one vault. So we don’t usually add a repo for 4-5 Obsidian vaults.
There are no settings in git (well, let’s assume we don’t need “settings” here now).
You create an empty repository online and clone it where you want it (use the GitHub Desktop program to make it easy for you). So I’d clone into /Documents/, not like you did there.
As I said, it is easier with a GUI like GH Desktop’s, where you see what you are doing.
If you think you put the folder in the wrong place just move the .git folder to another location (where the Obs. vault is) and then you’d need to locate for GH Desktop again (if you should choose to use that program).

About using git repos that are also synced via iCloud, well, I’d advise against it (unless you know what you are doing and your iCloud is properly set up or on you are on a Mac where setting these things up are more straightforward – I can’t find that Share&Showcase post now), or maybe have a setup where you manually sync the repo (vault) to the iCloud folder via FreeFileSync.

I urge you to look these sync, freefilesync, icloud+git topics up on the forum as these questions or similar have been asked before.

Disc: not a Mac user.

Thank you for your answer.

I want to add some more details for clarity.

I am on a MAC with MacOS and also have an iPhone.

I want to sync to a Windows machine but have only done the described configuration on the Mac so far.

The repository folder with the .git file is intentionally where it is and my personal Obsidian Vault is intentionally a subfolder of my repository and is NOT in itself a repository.

My reasoning is that in the future, I am likely to have more than one Obsidian Vault and I want all of them to live in the same repository and not have to create and setup a separate repository for each vault.

That is why I asked if there is a way to configure the Obsidian Git plugin to sync either the entire repository which is one folder above the vault OR, better yet, to sync only the vault folder to the Repository.

Git is more version control than sync. Meaning if you intend to use the Git plugin with frequent auto commits and pushes, you are liable to rack up large volumes of git packages which will make it more difficult to handle over time especially with repo limits of 2 (plus?) GB on GitHub.

Experiment if you will, cause that’s how you’ll learn.

  • By ‘experiment’ I mean, try using git generally; I’m hazy on how the Git plugin works – will it find the .git folder anywhere or – as I think it may work – expects the .git folder in the current vault, meaning what you intend to do would work only with non-Obsidian Git only.

Otherwise setting up different repos takes about an extra 20-30secs of your time each (on GitHub at least).

The only trouble I encountered when juggling multiple repos is on iOS using the A-Shell app. But you don’t intend to use that, as you want to use iCloud to sync to the handheld device (BTW, the Obisidan Git plugin is not optimized well for mobile use).
iCloud on iOS, again needs setting up so you won’t encounter offloading issues. Which topic, again, was discussed in 5-10 threads on this forum in the past few years.

Yeah, I am not concerned with the issues on IOS and I am OK with those, regardless if I use only iCloud or eventually decide to move that to Git as well.
My preferred option would be to keep my vault in either OneDrive or iCloud, but the iOS Obsidian, cannot load vaults from OneDrive (I did read the feature request topic) and iCloud is not available for me on the Windows work laptop, so neither of my preferred options is available for my use case.

As for what the Obsidian Git plugin is looking for in terms of the location of the .git file, I was asking this question and was trying to find a specific answer because of the options I see in its configuration.

From what you shared, it seems you either leave the current setting (you leave it unchanged as it is) or you can set a folder BELOW the vault root (any Git plugins you install for any vaults will only be concerned with its own vault), which is not what you want. There is no talk of ABSOLUTE path here, only relative, which is bad news for you then.

The second setting is apparently about renaming .git. Could be useful for someone but not helping you.

My recommendation is to not use this plugin. Use git independently with manual commits and pushes using GitHub Desktop or any other git client with a GUI. Then you can move the .git folder anywhere you want. But as I said it’s not good practice what you’re trying to do.

My final advice is to merge all your vaults into one but it won’t scale well, of course. Or you could look at Nested Vaults (search the forum), but that’s again, not recommended.

1 Like

Thank you for all the time you spared to look into this.

I think with how much trouble this is proving to be, I would just use the recommended setting for the vault folder being its own repository, or perhaps a manual sync. I already have a sync script on my Mac, just need to put that into a corn job and then look up something similar or as you say GUI-based for the Windows laptop.

And hope that the Obsidian developers put support for the IOS app to be able to load the vault from Onedrive or any other platform-independent cloud provider on the roadmap.

Thanks again and Happy New Year

Sorry, this was not phrased well: I should have written ‘a final option’.

A final thought on syncing to iOS: if iCloud sync is not feasible, especially from Windows (where you can try installing the Windows 7 executable, not the Microsoft Store one; read up on this as well if you will), you can use the Working Copy app on iOS (paid; see forum threads about this too), but – similarly to AShell – it also leverages the lesser libgit2 git library where one can encounter memory and delta issues when the repo becomes large (git cannot be installed on iOS unless you are jailbroken).

So in the long run, git can cause headaches when used across multiple platforms. This is why official Obsidian Sync is recommended.

Happy New Year

1 Like

Just wanted to finish this topic as it might be useful for someone in the future.

I thought that I could not use iCloud on my work Windows laptop just based on memory and assumption. I do remember that iCloud on Windows was very problematic and also, I though that my laptop would be locked down enough to not allow me to install iCloud.

Both of the above turned out to be only assumptions. I checked today and there is full support for iCloud for Windows 11 and when I tried to install it on my work laptop, it installed perfectly fine.

I only use iCloud for various backups, so with it able to be installed on my WIndows laptop, I can now use it to sync my Obsidian Vault across all my devices which is the way I decided to go forward, at least until the Obsidian IOS app starts being able to open a vault from Onedrive.

I think I will still keep my Git setup that I have done on my Mac and only set it up with a Cron job to back up my vault to Git once a day or so.

I will also not use the Obsidian Git plugin at all as it is not needed anymore.

Happy New Year everyone.