ext3, vfat and git: Not a .git repository

When setting up sys004 (my main productive system), I thought VFAT as filesystem at my main data partition would be a nice idea, because I can use it with Windows too and Linux supports it better than NTFS. However, it was a bad idea. Git refuses to work, whenever it cannot set file permissions (Note: vfat does not support this!) and the HEAD file’s filename is lowercased (Note: vfat lowercases filenames). So I copied all my data, reformatted the partition and got a ext3 filesystem (I think accessing data from Windows is not that important to me). Now git throws the error message:

fatal: Not a git repository (or any of the parent directories): .git

Execute those commands to make git work again. This is zsh-only (because of **/*):

# Get rid of whitespaces in filenames. Damn you, sh.
IFS='
'
# permission problem: Remove executable flag from all files for "all" for the entire new ext3 filesystem
find /media/ex_vfat -type f -print0 | xargs -0 chmod a-x
# lowercase problem: .git/head becomes .git/HEAD again.
for FILE in ./**/*/.git/head; do mv $FILE $(dirname $FILE)'/HEAD'; done;

This is it. Your git-repo should work again now properly. Mine did :-)

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>