According to man git clean
:
-d
Remove untracked directories in addition to untracked files.
In your case, directory conf/sar
is not tracked - it does not contain any files that are tracked by git. If you did not have gitignore rule and executed git clean -fd
, contents of this untracked directory would have been removed - just what documentation says.
Now, if you add .gitignore
with rule to ignore *.sar
files, it does not change basic fact that your directory conf/sar/
is still untracked, and having untracked file aaa.sar that is eligible for this gitignore rule should not suddenly make it unremovable by git clean -fd
.
But, if you add any tracking file next to your ignored aaa.sar
, then this directory would not be removed and your file will be left alone.
In other words, while it looks confusing, this is not a bug and git does exactly what documentation says.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…