Why does git clean -dX not remove my ignored directory?
I would like git to clean up all untracked files that I have ignored.
I thought that
git clean -dX was the obvious solution, but it does nothing:
# Set up test directory mkdir git-test && cd git-test git init && touch x && git add x && git commit -m Initial mkdir -p folder1/folder2/ touch folder1/folder2/file echo "folder2/" >> .gitignore git clean -fdX # Does nothing
Why is it not removing
The docs say that
**/foomatches file or directory
fooanywhere, the same as pattern
folder2/ pattern does match
-X should clean it.
What’s going on?
One Solution collect form web for “Why does git clean -dX not remove my ignored directory?”
What version of Git are you using? You may have run into this bug: Bug: git ls-files and ignored directories.
This bug was fixed in v18.104.22.168. From the release notes:
git ls-files --exclude=t -i” did not consider anything under
t/as excluded, as it did not pay attention to exclusion of leading paths while walking the index. Other two users of
excluded()are also updated.