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.

Fixes #11181.