.gitignore -> .stignore

I’m using Syncthing to synchronize several developer machines. In these cases, it’s often useful to ignore auto-generated files.

I already have lists of such files in the form of .gitignore files. However, these are not interpreted by Syncthing. This is why I created a script to update my .stignore based on the .gitignore files it finds. I’m posting the script here in the hope that it will be useful to others.

The script (sorry, new users cannot upload files…)

On that note, a question: would it be useful to have the two tools use the same format? I know it’s an incompatible change… but it feels wrong to me to have two slightly different mechanisms and file formats for essentially the same thing.

The format is loosely modelled on .gitignore. Can you outline what the main incompatibilities are? Maybe it’s something we could just tweak.

You shouldn’t sync git repos with syncthing:

Most likely it will corrupt your repos some times…

edit: Maybe I am just offtopic here… Sry.

There are legit circumstances in which to do that though, regardless of what I wrote in that post. For example, if it’s actually one way.

Some of the incompatibilities that I’ve found:

  • When a line contains a trailing slash, git ignores the slash but matches only directories. Syncthing does not support this. A line with a trailing slash will sync the folder but ignore all files inside.
  • Syncthing uses the first matching line to make a decision. On the other hand, git will include a file if a negated line comes after a matching line.
  • How ** is handled is slightly different. Git is fairly strict regarding what places ** can occur; foo**bar is accepted by Syncthing but not by git.
    EDIT: also, foo/**/bar matches foo/bar in git, but not in Syncthing, it seems.
  • Paths in git are relative to the .gitignore file. It is possible (and often useful) to have .gitignore files specific to a subdirectory.
  • More of a philosophy difference: .gitignore files are version controlled, but .stignore files are not synced. Git has a different mechanism for unshared ignores (~/.gitignore and .git/info/exclude).

Official git documentation

1 Like

The concern about syncing git repos is a valid one; maybe I should just exclude them all. I guess I could write another script that finds git repo folders and adds them to .stignore :slight_smile:

In one use case, I’m using Syncthing to synchronize a folder of notes from my laptop (where I have git) to my phone (where I don’t). It is two-way, but I can do all commits from the laptop.

1 Like