git filemode and fat32

Posted on Sunday, August 24, 2014


Recently I have been on a journey setting up backup systems for my personal files and notes.  This system is using git and a few scripts that utilized rsync to get the job done.

At work, on my work laptop, I decided to keep my personal git repository on a small SanDisk Cruzer Fit USB Drive.  That way when/if I leave this job or get my laptop replaced its easy to take "My" files with me.

Looking at the file permissions on the thumb drive


     > ls -alh





I saw that the permissions were set to 777.    Which were not what they were originally set to.

I did a quick test and cloned the repo from the remote repository I set up on another drive.  The permissions were correct!  But every time I tried to do it on the USB thumb drive I had the wrong permissions.

What is the difference?


Looking at .git/config I found the difference.



     > cat .git/ignore | grep filemode


On the USB drive git repo I got back

filemode = false

Everywhere else I got

filemode = true




I see
core.fileMode
If false, the executable bit differences between the index and the working tree are ignored; useful on broken filesystems like FAT. See git-update-index(1).
The default is true, except git-clone(1) or git-init(1) will probe and set core.fileMode false if appropriate when the repository is created.

When I cloned the repo to a FAT32 file system git was smart enough to set this feature to off.

When this feature is on git will track permission changes.  But only executable permission changes? To be honest I am a little bit lost on this point, I need to read up more on how git deals with permissions.  Currently, I am not finding any simple information I can digest in 30 minutes.  I need to buy a few books and do some research.

In the meantime it's good to know that git is smart enough to deal with FAT32 filesystems.





References
[1]  git config Manual Page

       Visited 8/2014

No comments:

Post a Comment