If I rename some directories, then commit and push to the origin, and later pull from another computer I will find both the old an new directories. In the old directories there will be some ignored files. How do I remove all such untracked directories, without touching any file (tracked or untracked) in any tracked directory.
(With "tracked directory" I mean a directory with at least one tracked file inside.)
You may be after
git clean -X
.From git-scm
Here's an example with one tracked, one untracted and one ignored file.