How can I edit a correct .stignore file by using “!” prefix

How can I edit a correct .stignore file by using “!” prefix

The IGNORE file(.stignore) seems never work, my fault?

IDK how capture these details, but it did happen!!

Currently synchronized between PC and Android phones. I just want specific types of files to be synchronized between devices.

There is a folder which contains some pictures(jpg,png),ofcourse, it contains other miscellaneous files or folders.

Then I just want to sync pictures between my PC and my Android phone(have installed ST APP), so I wrote the patterns: ("!"prefix. Whether I edited it by WEB GUI or edited the .stignore it directly)

(?i)!/*.jpg
(?i)!/*.png

and

(?i)!/*\.jpg
(?i)!/*\.png

and

(?i)!*.jpg
(?i)!*.png

and

(?i)!*\.jpg
(?i)!*\.png

Unfortunately, it doesn’t work either, it always not synchronized pictures only but synchronized other files or folders, not just the .jpg, .png files, so i assumed that the ‘.stignore’ doesn’t work.

But if it was specified file name, files were ignored successfully(this is ignore mode, right)

(?i)testFolder*
(?i)miscellaneous*

But obviously that’s a bit cumbersome and a bit stupid… So, if I want to use the “!” prefix, how should I write the. stignore file?

Excuse me, my English is limited. There may be ambiguities in the statement.

[Chinese Description]

Summary

目前是在PC和Android手机之间同步。我只是想让特定类型的文件在设备之间同步啊!

我这有一个文件夹(有图片、文本文件等),不过同步仅仅是里面的 .jpg 和 .png 文件,于是我编写了如下规则,"/"是为了保证只同步根路径的 .jpg 和 .png 文件:

(?i)!/*.jpg
(?i)!/*.png

但很不辛,这样并不起作用,除了.jpg 和 .png 文件的其他文件也被同步了,这样可不行,遂改为:

(?i)!/*\.jpg
(?i)!/*\.png

依然不起作用,接着是:

(?i)!*.jpg
(?i)!*.png

没区别,还是没用,再然后:

(?i)!*\.jpg
(?i)!*\.png

还是不起作用。。 但是如果是具体的文件名,就可以做到忽略填写的文件(这是 ignore 模式吧)

(?i)testFolder*
(?i)miscellaneous*

但显然这样做有点麻烦并且有点蠢。。。 所以,如果我想使用 "!"修饰,应该怎么编写 .stignore 文件?

Did you add a wildcard (*) as last entry? For example;

(?i)!*.jpg
(?i)!*.png
*

Don’t forget that these are ignore patterns and should be seen as such. So if you want to reverse it, it’s definitely possible, but then you need to explicitly ignore all the other files, all the files that you did not “include” using the ! prefix.

2 Likes

Thank you very much, yes, you are so great that what you said is indeed the point, :joy_cat: :joy_cat: I really did not ignore all the other files.

2 Likes