Frage

Is there a way to exclude an entire directory from git if a certain file is present in there?

For instance, I have a lot of test cases which create new directories with an _SUCCESS file. I want to exclude any directory that has a _SUCCESS file. I do not care about what other files are in there.

War es hilfreich?

Lösung 2

list of files/directory which are listed in ".gitignore" file are excluded in pushing into git repository. ".gitignore" file accepts static list of files/directories. Hence solutions availalbe:

i) you can create a directory "temp_success" so that your test cases tries to generate directories/files in "temp_success". Add this directory "temp_success" into .gitignore file temp_success/* .

ii) After running your test cases, write a script/code to check directories having SUCCESS file and execute following script to stop pushing into git repository

git update-index --assume-unchanged path/to/file.txt

Follow the reference at:

https://help.github.com/articles/ignoring-files

Andere Tipps

As far as I know, that is not possible.
After reading the gitignore manpage gitignore(5), I did not found any possibility to regex an ignore.

Maybe it is more reliable to create a test directory and run your tests in that directory and exclude just the full test directory.
Maybe I'm wrong but there is no way like "exclude if", wich is IMHO not the philosophy of gitignore.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top