https://github.com/user-attachments/assets/4314fe67-8e0c-4330-8240-e751392f3837
Local Git Sync is an unofficial Obsidian desktop plugin for users who manage their vaults with Git. It helps you commit, pull, push, and auto-sync vault changes without leaving Obsidian.
This plugin uses the local Git executable on your machine and works with GitHub, GitLab, Gitee, or self-hosted Git remotes that you configure yourself.
After the plugin passes review, it can be installed from the Obsidian Community Plugins directory.
VaultFolder/.obsidian/plugins/local-git-sync/main.jsmanifest.jsonstyles.cssLocal Git Sync in Settings -> Community plugins.Run this in a terminal:
git --version
If Git is not available on your PATH, install it first. On Windows, the plugin can also detect common default Git installation paths. If needed, you can set a custom path in the plugin settings.
Open a terminal in your vault root:
git status
If the vault is not a Git repository yet:
git init
git add .
git commit -m "Initial vault commit"
If your vault is stored inside a larger Git repository, the plugin will operate on that repository, not only on the vault subfolder.
Example using HTTPS:
git remote add origin https://github.com/your-name/your-vault.git
Example using SSH:
git remote add origin [email protected]:your-name/your-vault.git
Before using the plugin, test standard Git commands:
git pull origin main
git push origin main
If these commands fail in the terminal, the plugin will fail too. Fix authentication first through your Git credential manager, token, or SSH key setup.
After enabling Local Git Sync, review these settings:
Git remote: defaults to originBranch: leave empty to use the current checked-out branchGit executable path: optional custom path to gitAuto sync delay: wait time after changes stopBackground sync interval: periodic fallback syncSync on startup: sync shortly after opening the vaultCreate placeholders for empty folders: keep empty folders trackable by GitPlaceholder file name: default is .empty-folder.mdShow success notices: controls success popupsOpen the command palette and run:
Local Git Sync: Sync now
Typical flow:
The plugin listens for create, modify, delete, and rename events in the vault. After edits settle for a short time, it starts an automatic sync. A background interval also runs as a fallback.
git pull --rebase reports a conflict, the plugin shows a warning.Install Git first and verify git --version. If Git is installed but not on PATH, set a custom Git executable path in the plugin settings.
Test these commands first:
git fetch origin
git pull origin main
git push origin main
If they fail, fix your credential helper, token, or SSH configuration outside Obsidian.
Use the same remote and branch on every device. Make sure each device can pull and push independently before relying on automatic sync.
Not in the current release. Initialize the repository manually before enabling automatic sync.
This plugin is unofficial and is not affiliated with, endorsed by, or sponsored by Obsidian.
Local Git Sync 是一个非官方的 Obsidian 桌面插件,适合已经使用 Git 管理笔记库的用户。它可以帮助你直接在 Obsidian 中完成提交、拉取、推送和自动同步。
这个插件依赖你本机安装的 Git,可配合 GitHub、GitLab、Gitee 或自建 Git 远程仓库使用。所有远程连接和认证都通过你自己的 Git 配置完成。
pull --rebase 发生冲突时给出提示插件通过审核后,可在 Obsidian Community Plugins 中直接安装。
VaultFolder/.obsidian/plugins/local-git-sync/main.jsmanifest.jsonstyles.css设置 -> 社区插件 中启用 Local Git Sync。在终端运行:
git --version
如果系统无法识别 Git,请先安装 Git。Windows 下插件会尝试识别常见的默认安装路径;如果仍然找不到,可以在插件设置中手动填写 git.exe 路径。
进入 vault 根目录,运行:
git status
如果当前 vault 还不是 Git 仓库,可以先执行:
git init
git add .
git commit -m "Initial vault commit"
如果你的 vault 是放在一个更大的 Git 仓库里面,插件会对那个仓库执行同步,而不只是针对 vault 子目录。这一点需要你提前确认。
HTTPS 示例:
git remote add origin https://github.com/your-name/your-vault.git
SSH 示例:
git remote add origin [email protected]:your-name/your-vault.git
建议先在终端测试:
git pull origin main
git push origin main
如果这些命令在终端里都不能正常工作,插件里也同样无法正常同步。需要先把 Git 的认证问题解决,比如 credential manager、token 或 SSH key。
启用 Local Git Sync 后,建议重点检查这些配置项:
Git remote:默认是 originBranch:留空时使用当前已检出的分支Git executable path:可选,自定义 git 路径Auto sync delay:文件改动停止后等待多久再同步Background sync interval:后台定时补偿同步间隔Sync on startup:打开 vault 后是否自动同步一次Create placeholders for empty folders:是否为空文件夹创建占位文件Placeholder file name:占位文件名,默认 .empty-folder.mdShow success notices:是否显示成功提示打开命令面板,执行:
Local Git Sync: Sync now
通常流程如下:
插件会监听 vault 内的创建、修改、删除、重命名事件。你停止编辑一小段时间后,它会自动触发同步。同时还会有一个定时检查作为补偿,避免漏掉某些没有触发事件的仓库变更。
git pull --rebase 出现冲突,插件会给出警告先安装 Git,并确认 git --version 可以正常运行。如果 Git 已安装但不在 PATH 中,可以在插件设置里手动填写 Git 可执行文件路径。
先在终端测试:
git fetch origin
git pull origin main
git push origin main
如果这些命令失败,请先修复 Git 本身的认证配置,再回到 Obsidian 使用插件。
建议所有设备都使用同一个 remote 和同一套分支策略,并分别确认每台设备都能独立完成 pull 和 push,再依赖自动同步。
当前版本不包含这个功能。建议你先手动完成 Git 初始化,再启用插件。
This plugin is unofficial and is not affiliated with, endorsed by, or sponsored by Obsidian.