Set Syncthing Excluding A Repo's git Directory

使用 Syncthing 时在不同主机端间同步文件,如果在同步完成前就对端操作,会生成临时的冲突文件 .sync-conflict*

如果同步的目录包含 git 仓库,建议取消掉仓库的 .git 目录:在使用中若 syncthing 未同步完全时就切换主机进行 git 操作,很容易在 .git 目录中产生 syncthing 冲突文件,并且使用者会无感直到某天发生了 .git 崩坏的问题,虽然大多数情况下并没有什么影响。

对此在 syncthing 的同步根目录中设置 .stignore1 来忽略掉,也可以在 syncthing 的 web 后台中设置。例如: _20250531_220641screenshot.png Syncthing Directory Ignore Patterns Setting

当然也可以直接在 syncthing 某根目录的 .stignore 中配置如下字段,可以忽略该目录下的所有仓库的 .git 目录:

**/.git

这样就避免了在 Syncthing 同步包含仓库目录时 .git 目录中出现 syntching 冲突文件了。当然问题本质在于 .git 和 syncthing 都有同步功能,多数情况下选择一种即可:要么不要将 git 仓库放在 syncthing 中同步,要么在 syncthing 中完全忽略 git 仓库。对于已经熟悉 git 操作的用户来说,选择自己最喜欢的方式就可以。