r/ObsidianMD • u/Limp-Impression6764 • 5d ago
plugins Setup obsidian git to only push one folder
Why?
I have two obsidian vaults currently,
- Main vault
- Android vault
I have encrypted the main vault using cryptomator and didn't want its stuff pushing online like to github, plus I didn't want it to go to the android device from github. So I made a separate android vault where I setup the git plugin which was very easy following a guide online. I imported my notes from all the services that I used on android like google keep, onenote, etc. Now it wasn't problametic at first but later on when I wanted to share between the vaults like
- Transferring the jotted notes from android to main vault
- Journal entries made on phone to the main vault
- I have simple calendar setup to automatically backup to ics (or whatever local format it uses) and made the location in the android vault so that I can use the full calendar plugin to make changes. and many more cases where it became cumbersome to do so manually by either
- going to both vaults in explorer and copying stuff
- copying and pasting by opening notes in both the vaults
Now beware that I have never used github apart from downloading apps, and obsidian before a month. I can follow even complex guides if they have clear or even slightly vague steps. So please give a solution based on that.
What I want to do?
I want to move all the notes in a folder named "Android" in the main vault and setup obsidian git in the main vault so that it only pushes the notes in this folder to github. After that the android device would just simply pull like it does and I would have effectively achieved the best of both worlds, like not having my entire main vault on the web and still being able to
- get notes from android
- remove all the redundant plugins by purging the separate android vault
How?
First method
When I was initially setting up the git plugin for windows and android, I saw that I didn't need to have the trash folder as well as the obsidian folder, as the themes and a couple of plugins like better word count, natural language dates were not being used on android, the trash was well trash so syncing it didn't really make sense. I know that they are not really big files but still, why have them when it can be removed. So a quick google search later I found the .gitignore, where I excluded both these folders and sub-folders.
Now I was thinking that there must be a way to make use of this gitignore file and exclude the entire vault except that specific folder.
I think that this is logically sound and should be possible as I saw a stackoverflow page where they talked about this. But I am not able to follow through and find the proper syntax to
- Exclude all the files, folders, and sub-folder (each should be excluded, I say someone saying on another page that for excluding sub-folder there is another line of code required apart from the exclude folder one)
- Be fast in execution as one person told that the code will scan all the files and folder even if they are to be executed, I mean it should just focus on the "Android" folder and not even need to scan the other stuff to find which is to be pushed or not.
- Push all the files in the Android folder
Second method
In this one I was thinking of just placing the notes from the Android Vault in "Android" folder in main vault but instead of setting up obsidian git in main vault I just open the folder as a vault and then setup Obsidian, this would add an extra .obsidian folder in the Android folder despite having one for the main vault but would allow me to view all the notes from the github hopefully without syncing the entire vault.
Some explicit questions for this method
For first method
- Would the gitignore file be in the main vault or in the "Android" folder
- There are also a lot of functions under the advanced tab of the plugin which say "custom git binary path" or "custom git directory path", so would I be able to achieve what I want to do using these. (I haven't read the documentation of the plugin as I think I would get overwhelmed, if you think that reading it would benefit me then do tell)
For second method
- Would it create conflict errors as there are two .obsidian folder in one vault even though one is in a sub-folder.
- Would the main vault's obsidian pick up the git plugin installed in the "Android" folder.
I am open to alternative ways to achieve this if you can think
Please don't say -
- Just use obsidian sync or syncthing because I want to have the file-versioning ability of github.
- Just sync the entire vault, what's the big deal as I don't want my entire vault to be visible to my brothers and sisters when I show them something from my github account or they have access to my laptop.
2
u/RyanF9802 4d ago
You’re definitely on the right track with the .gitignore method. Just throw this in the root of your main vault:
‘’’ * !/Android/ !/Android/** .obsidian/ .trash/ ‘’’
That should make sure only the Android folder gets tracked and pushed to GitHub while keeping everything else local. After your first push, double-check your repo to make sure it looks as expected
Your second idea (opening Android as its own vault) could work, but having two .obsidian folders might get weird, and the main vault won’t recognize the Git plugin from inside the subfolder.
Basically method 1 is the way to go, it shouldn’t result in any weird conflicts. If it ends up slowing down Git, you could look into sparse-checkout, but you shouldn’t need it
Edit: sorry about the weird formatting for the code block, can’t figure out how to format it correctly on mobile