# .gitignore -\> .stignore

**URL:** https://forum.syncthing.net/t/gitignore-stignore/5746
**Category:** General
**Created:** [September 23, 2015, 10:30am UTC](https://forum.syncthing.net/t/gitignore-stignore/5746 "2015-09-23T10:30:05Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Sjlver](https://forum.syncthing.net/user_avatar/forum.syncthing.net/sjlver/32/1975_2.png) [@Sjlver](https://forum.syncthing.net/u/Sjlver)
#### Post date: [September 23, 2015, 10:30am UTC](https://forum.syncthing.net/t/gitignore-stignore/5746/1 "2015-09-23T10:30:05Z")

</div>

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](https://documents.epfl.ch/users/j/jo/jowagner/www/gitignore_to_stignore.rb) (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.

---

<div class="post-metadata">

### Author: ![calmh](https://forum.syncthing.net/user_avatar/forum.syncthing.net/calmh/32/15311_2.png) [@calmh](https://forum.syncthing.net/u/calmh)
#### Post date: [September 23, 2015, 10:32am UTC](https://forum.syncthing.net/t/gitignore-stignore/5746/2 "2015-09-23T10:32:07Z")

</div>

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

---

<div class="post-metadata">

### Author: ![rumpelsepp](https://forum.syncthing.net/user_avatar/forum.syncthing.net/rumpelsepp/32/2006_2.png) [@rumpelsepp](https://forum.syncthing.net/u/rumpelsepp)
#### Post date: [September 23, 2015, 10:33am UTC](https://forum.syncthing.net/t/gitignore-stignore/5746/3 "2015-09-23T10:33:01Z")

</div>

You shouldn’t sync git repos with syncthing:

> [@Is putting a Git workspace in a synced folder really a good idea?](https://forum.syncthing.net/t/is-putting-a-git-workspace-in-a-synced-folder-really-a-good-idea/1774/9):
>
> You can, and it’ll sync just fine, but you shouldn’t. A Git repository is not like a collection of documents. In a collection of documents, each file is mostly independent so it’s easy to “merge” when one file has changed on one device and another file on another device. A Git repository on the other hand is made up of a bunch of files that should be internally consistent with each other. “Merging” two Git repositories that have diverged cannot be done by just copying in the newest files from …

Most likely it will corrupt your repos some times…

edit: Maybe I am just offtopic here… Sry.

---

<div class="post-metadata">

### Author: ![calmh](https://forum.syncthing.net/user_avatar/forum.syncthing.net/calmh/32/15311_2.png) [@calmh](https://forum.syncthing.net/u/calmh)
#### Post date: [September 23, 2015, 10:33am UTC](https://forum.syncthing.net/t/gitignore-stignore/5746/4 "2015-09-23T10:33:53Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Sjlver](https://forum.syncthing.net/user_avatar/forum.syncthing.net/sjlver/32/1975_2.png) [@Sjlver](https://forum.syncthing.net/u/Sjlver)
#### Post date: [September 23, 2015, 12:18pm UTC](https://forum.syncthing.net/t/gitignore-stignore/5746/5 "2015-09-23T12:18:55Z")

</div>

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](https://git-scm.com/docs/gitignore)

---

<div class="post-metadata">

### Author: ![Sjlver](https://forum.syncthing.net/user_avatar/forum.syncthing.net/sjlver/32/1975_2.png) [@Sjlver](https://forum.syncthing.net/u/Sjlver)
#### Post date: [September 23, 2015, 12:21pm UTC](https://forum.syncthing.net/t/gitignore-stignore/5746/6 "2015-09-23T12:21:36Z")

</div>

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` 🙂

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.
