How to avoid a directory from being removed

32 Views Asked by At

I wanted to know if there is a way to create a file inside a directory that avoids it to be removed by a simple rm -r, just like when we have a Git respository and it is not deleted because of the .git file.

1

There are 1 best solutions below

0
VonC On

As far as I know, such a feature does not exist natively.

The convention is to add a .keep dummy file in a folder you want to include n your git repository (especially if this folder starts empty, since Git does not version empty directory).

But nothing would prevent an OS command (like rm/del/delete) to actually delete the folder, and Git to detect that deletion in its status.