I am using the Git plugin to periodically back up my notes (and also sync them to other machines) by pushing them to a GitHub repository. I want it to back up only:
Settings, keybindings, etc
Plugins/Themes
My notes
That’s it.
…and NOT caches or anything super volatile that does not affect my setup.
Things I have tried
Not ignoring anything: Not ideal because sometimes changes would appear in the version control tab while I was doing literally nothing (like workspace.json or data.json (might be forgetting some)). My commits got really crowded because of it, even though it technically worked.
Ignoring the entire .obsidian folder: Also not ideal because I would need to redo my setup on every place I want to pull my notes to. Also, I tried to pull from the repository at one point and it deleted the existing .obsidian folder, despite the fact that it should not care, which sucked.
What I’m asking for
I guess what I’m after is somewhere in between. Basically, only changes to settings/keybindings, plugins/themes, or my actual notes should matter. So, for the git experts in this community, what would that .gitignore look like?
After some headaches, chatgpt conversations, and some mild testing, I think I found a gitignore that works for what I have in mind. It basically ignores UI-specific state like workspace.json and app.json, while keeping everything else. That seems to work and cut down on unnecessary changes. Here is that file. Feel free to add to it:
# Ignore volatile UI-related state
.obsidian/workspace.json
.obsidian/app.json
# Ignore system and editor files (more specific to what I do)
.vscode/
.idea/
.DS_Store
Thumbs.db
The index should only contain the items you wish to track. Files you do not want to monitor, even if in the same folder, can be excluded from Git. This means you must manually add each file or folder that you want Git to track. Any file not added will be excluded from the index, although it will appear as untracked when you use the status command. To prevent that, set a flag—local to the repository—to hide files you are not explicitly tracking yet. This will prevent files you are not interested in tracking from showing up as untracked when you type git status and other commands later.
Prevent untracked files from showing:
git config --local status.showUntrackedFiles no
My .gitignore file excludes large files needed by certain plugins, which are too large to sync via GitHub. This forces the plugin to create the file on every device where it is installed.
# Ignore Dolphin File Explorer Directory Settings
.directory
# Ignore Smart Connections folder
.smart-connections
# Ignore Copilot file due to size
.pro/copilot-index-*.json