# Please pls help me write my ignore

**URL:** https://forum.syncthing.net/t/please-pls-help-me-write-my-ignore/24622
**Category:** Support
**Created:** [July 12, 2025, 1:35pm UTC](https://forum.syncthing.net/t/please-pls-help-me-write-my-ignore/24622 "2025-07-12T13:35:40Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Cage4243](https://forum.syncthing.net/letter_avatar_proxy/v4/letter/c/7ea924/32.png) [@Cage4243](https://forum.syncthing.net/u/Cage4243)
#### Post date: [July 12, 2025, 1:35pm UTC](https://forum.syncthing.net/t/please-pls-help-me-write-my-ignore/24622/1 "2025-07-12T13:35:40Z")

</div>

Please pls help me write my ignore

```plaintext
// ignore all directories except for above
*

// do not exclude txt
(?i)!**.{md,txt}

// ignore .trash
.trash

```

This doesn’t ignore anything, and I’m not sure which part went wrong

My goal:

- sync only text file (except for text file in .trash)
- do not sync anything in .trash

thanks a great lot in advance

---

<div class="post-metadata">

### Author: ![tomasz86](https://forum.syncthing.net/letter_avatar_proxy/v4/letter/t/96bed5/32.png) [@tomasz86](https://forum.syncthing.net/u/tomasz86)
#### Post date: [July 12, 2025, 1:47pm UTC](https://forum.syncthing.net/t/please-pls-help-me-write-my-ignore/24622/2 "2025-07-12T13:47:21Z")

</div>

The order does matter, so you probably want:

```plaintext
// do not exclude txt
(?i)!*.{md,txt}

// ignore all directories except for above
*

```

The two ` **` are also redundant. They are only needed when you have patterns like `directory/*/file` and `directory/** /file`, which will match different contents. In addition, `*` already matches everything, so there is no need for a separate `.trash` entry above it.

---

<div class="post-metadata">

### Author: ![Cage4243](https://forum.syncthing.net/letter_avatar_proxy/v4/letter/c/7ea924/32.png) [@Cage4243](https://forum.syncthing.net/u/Cage4243)
#### Post date: [July 13, 2025, 12:56am UTC](https://forum.syncthing.net/t/please-pls-help-me-write-my-ignore/24622/3 "2025-07-13T00:56:54Z")

</div>

thank you so much! But I realize I made a mistake in my post. What I actually meant is

My goal:

- sync only text file (but not the text file in .trash)
- do not sync anything in .trash

This ignore provided seems to sync the text file in my .trash, which is not what I wanted.

```plaintext
// do not exclude txt
(?i)!*.{md,txt}

// ignore all directories except for above
*

```

Could you also explain how order matters in ignore? I can’t seem to find it in the official document

@tomasz86

---

<div class="post-metadata">

### Author: ![tomasz86](https://forum.syncthing.net/letter_avatar_proxy/v4/letter/t/96bed5/32.png) [@tomasz86](https://forum.syncthing.net/u/tomasz86)
#### Post date: [July 13, 2025, 5:32am UTC](https://forum.syncthing.net/t/please-pls-help-me-write-my-ignore/24622/4 "2025-07-13T05:32:04Z")

</div>

> [@Cage4243](#):
>
> Could you also explain how order matters in ignore? I can’t seem to find it in the official document

Basically, if a previous patterns matches something already, then you cannot “unignore” it afterwards. This is why if you put `*` first, then everything gets ignored at the very beginning and you’ve got nothing to work with anymore.

Taking `.trash` into account, you probably want this then:

```plaintext
// ignore .trash
.trash

// do not ignore md and txt
(?i)!*.{md,txt}

// ignore all except for above
*

```

---

<div class="post-metadata">

### Author: ![Cage4243](https://forum.syncthing.net/letter_avatar_proxy/v4/letter/c/7ea924/32.png) [@Cage4243](https://forum.syncthing.net/u/Cage4243)
#### Post date: [July 13, 2025, 5:49am UTC](https://forum.syncthing.net/t/please-pls-help-me-write-my-ignore/24622/5 "2025-07-13T05:49:04Z")

</div>

thanks a lot! @tomasz86

---

<div class="post-metadata">

### Author: ![acolomb](https://forum.syncthing.net/user_avatar/forum.syncthing.net/acolomb/32/11343_2.png) [@acolomb](https://forum.syncthing.net/u/acolomb)
#### Post date: [July 13, 2025, 6:30am UTC](https://forum.syncthing.net/t/please-pls-help-me-write-my-ignore/24622/6 "2025-07-13T06:30:22Z")

</div>

> **[Ignoring Files — Syncthing documentation](https://docs.syncthing.net/users/ignoring.html#patterns)**

The second sentence in that paragraph tells you the order is important.

---

<div class="post-metadata">

### Author: ![Cage4243](https://forum.syncthing.net/letter_avatar_proxy/v4/letter/c/7ea924/32.png) [@Cage4243](https://forum.syncthing.net/u/Cage4243)
#### Post date: [July 14, 2025, 2:12am UTC](https://forum.syncthing.net/t/please-pls-help-me-write-my-ignore/24622/7 "2025-07-14T02:12:47Z")

</div>

> The _first_ pattern that matches will decide the fate of a given file.

This sentence?

---

<div class="post-metadata">

### Author: ![chaos](https://forum.syncthing.net/letter_avatar_proxy/v4/letter/c/9d8465/32.png) [@chaos](https://forum.syncthing.net/u/chaos)
#### Post date: [July 14, 2025, 3:35pm UTC](https://forum.syncthing.net/t/please-pls-help-me-write-my-ignore/24622/8 "2025-07-14T15:35:23Z")

</div>

Think of an Ignore Pattern as being like an access list in this regard:

The file is evaluated by the first line in the Ignore Pattern. If there’s a match (whether it’s to ignore or to unignore), the action is taken and the ignore process exits: in other words, further lines in the Ignore Pattern file are not evaluated for that file.

This continues, line by line, until there is a match. The action is taken and further lines are not evaluated.

The final, “implied” line of the Ignore Pattern is to allow everything.

---

<div class="post-metadata">

### Author: ![Cage4243](https://forum.syncthing.net/letter_avatar_proxy/v4/letter/c/7ea924/32.png) [@Cage4243](https://forum.syncthing.net/u/Cage4243)
#### Post date: [July 15, 2025, 10:46am UTC](https://forum.syncthing.net/t/please-pls-help-me-write-my-ignore/24622/9 "2025-07-15T10:46:28Z")

</div>

thanks a lot!

---

<div class="post-metadata">

### Author: ![system](https://forum-uploads.syncthingcdn.net/original/2X/0/0b50e0a202b22ae6a67190759e8c868805b8ed9f.png) [@system](https://forum.syncthing.net/u/system)
#### Post date: [August 14, 2025, 10:46am UTC](https://forum.syncthing.net/t/please-pls-help-me-write-my-ignore/24622/10 "2025-08-14T10:46:45Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
