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
1. Create a subfolder "project" in a synced folder
2. Initialize a git-repository in that subfolder
The whole subfolder "project" does not get synced to owncloud
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.
Did you try Regular Expressions like in the link above? That should include all with a specific name or something which contains the 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:
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 know that, but it doesn't answer my original question; can I exclude a folder based on its contents? (And not based on its name.)
Only so like I explained and it is described in the link.
I have exact the same problem. Did you find any suitable solution?
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
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