Fix edge case when rel path changes from file to dir

This fixes an edge case in gitfs where a path that once was a file is
now a directory.
Merge pull request #11280 from terminalmage/issue11181

Fix edge case when rel path changes from file to dir