Wednesday, November 18, 2009

Git on a Flash Drive

Had some serious trouble figuring this one out...

The Idea: Use Git for source control on my Debian laptop, and keep a copy of the repository on a USB Flash Drive.

It should work something like this:

on flash drive:
mkdir project
cd project
git --bare init
on desktop:
git clone /path/to/usb/drive
make changes
git add .
git commit -m "did something"
git push origin master
But it didn't quite work that way

git clone resulted in the error messages "unable to chdir or not a git archive"
and "The remote end hung up unexpectedly"
The problem here is one of case-sensitivity. Git looks for a file named HEAD.
ls
branches config description head hooks info objects refs
but HEAD is lower case on the flash drive.

Attempts to Fix:
  • Renaming it to head results in an error (its already there).
  • Renaming to a temporary name and then to HEAD results in head showing up again.
So I look around on the drive and find out that NOT every file which has its name downcased. I check properties, and the flash drive is mounted using VFAT. In my configuration (Applications/System Tools/Configuration Editor) I check the VFAT settings (system/storage/default_options/vfat) and see a mount option of shortname=lower. I change this to mixed, remount the floppy and head is now HEAD.

Go google shortname=lower to find the world's opinion of this default...

Anyway, Git works on USB Flash Drives!

No comments: