Fix pruning

Turns out that relying on the '.git' file is not reliable. We will instead look for a '.git' directory to prune
closes #3853