Make sure gitdir exist

inside .git folder git rev-parse --show-toplevel would return empty
text.