Fix for #2739 (and #1755), added support for directory excludes in the gitignore file

Fix for #2739 (and #1755) added support for directory excludes in the gitignore file like /directory or directory/

For 1755 I added unittests to prove it has been fixed already.