Is there a possibility to ignore a whole folder based on its contents?
I have synced my whole documents folder to owncloud, but I want to exclude all git-repositories that are scattered within the documents-folder. I know I can exclude the .git-subfolders easily, but can I also ignore the whole folder containing my working copy based on the fact that it includes a .git-subfolder?
Steps to reproduce
Create a subfolder “project” in a synced folder
Initialize a git-repository in that subfolder
Expected behaviour
The whole subfolder “project” does not get synced to owncloud
Actual behaviour
I can ignore the .git-folder within “project” using ignored files editor (matching “.git”), but I would have to explicitly exclude “project” if I don’t want it to get synced.
Thanks for the quick response. I am aware of the possibility of excluding each such directory individually, but I’d rather have one single pattern that excludes every directory that contains a file or folder with a specific name.
The way I understand the pattern matching, that wouldn’t really work. Let’s assume I have two subfolders in my synced folder: “c-project” and “matlab_code”.
Both folders are git-repositories and contain a “.git”-folder. The fnmatch-expression I can think of is:
*/.git
but this pattern matches only the “.git”-folders themselves, and neither “c-project” nor “matlab_code” is matched and thus excluded.
Maybe my understanding is wrong and there is an expression that also matches these two folders (and every other folder containing “.git”), but I have currently no idea what that expression would be (apart from explicitly excluding both folders as ignored files).
You can use */, if you want to match all directories. /.git matches only all .git directories.
You would be able to use "_code/", if both directories would have a end with “_code”.
I’m also in a similar situation.
Ideally I’d like to ignore particular folders using say a .syncignore file in a directory, that serves as a flag.
What I have tired
*/.syncignore
.syncignore/
*/.syncignore/*
Haven’t been able to figure out the right ignore match for this - any pointers?
Please don’t revive such old topics. Just open a new one. Even if there was a correct solution for something back in the day, it might very well be outdated. — closed