Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using GIT on a Windows 7 machine (64 bit) and have been learning how to use GIT to version control my files.

Now I want to be able to create a --bare repository on an external device (in this case a 16gb USB stick) but unfortunately when I try to create a --bare repository on it I get the following error:

f:/: Permission denied

I am using the GIT Bash program which is installed with GIT on Windows machines, so these are the commands I am typing in (I am also opening the program as administrator by holding ctrl + shift when I open it)

cd /f
git init --bare
f:/: Permission denied

However if I create a normal repository it works just fine:

cd /f
git init
Initialized empty repository in f:/.git/

Can anybody shed some light on why I can't create a --bare repository?

Any help would be much appreciated.

share|improve this question
up vote 2 down vote accepted

UNIX systems, when you try to create a directory that already exists, return a "directory already exists" error. Windows will return a "permission denied" error if you could not create the directory if it didn't exist, even if it in fact does already exist. This gets a lot of programmers in trouble when they port UNIX code to Windows.

When you try to create a bare repository as f:\, the first thing git does is creates the directory to store it. It's expecting that if the directory already exists, it will get a "directory already exists" error. However, f:\ is a drive to Windows. Windows interprets this as the program attempting to create a drive, and it denies git permission to do that. Since git doesn't understand this Windows quirk, it thinks it has no permission to access the directory.

The solution is to create the repository in a sub-directory.

(And to those who write/maintain git: Trying to create a directory to make sure it exists and then aborting if you get an error is wrong behavior. If you are creating a directory just to make sure it exists and you fail -- for any reason -- you should then check to see if the directory exists. This has caused many bugs in many different programs (like this one) and, gosh darn it, you guys should know this by now.)

share|improve this answer
Thank you! I had no idea that git did things that way (I have only just started using it). In any case, it is working now so thank you very much for your help. – Jake Lucas Apr 6 '12 at 4:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .