Allow .git folder other than in the project root to be committed

1) Allow .git/ folder to be committed other than in the parent folder.(#2366)
2) Fix a bug where a folder was incorrectly reported untracked.

@devoncarew