tags:

views:

77

answers:

1

I have an existing project that has been managed under git. I recently had to do a ground-up rebuild of the computer (OS X Snow Leopard), and returning to the project, git can track the changes in the project, but I can't save anything to git. I get the error in the title when I try :

Dans-iMac-335:[app-name-obscured] apple$ git add app/models/*
fatal: Unable to write new index file

What's the best way to recover from this situation? There is a heroku repository version of this, but it is very out of sync with this one. presumably I could use a new clone as a basis, and update each file, but that seems over laborious and error prone.

What is git looking for here that it can't find, and is there a change that will restore it?

BTW, file permissions are correct from what I can tell - the files under control and the .git components are both owned by me with rw access...

+1  A: 

Do you have write access to .git (=can you create new files there and edit existing ones)? If not then adjust the file permissions.

If you have write permissions it seems you found a bug. You can try to recover by

  1. create a clone from your current working copy
  2. remove all files from the working copy of the clone
  3. copy all wc files from your current working copy to the clone (and don't copy .git)
  4. try to commit something in the clone.

When the last step works you need setup the remote branches from your current repo to the clone, and then you can use the cloned repo as your new working copy.

Rudi
Rudi is almost certainly right. Even if the *name* of the account on your old machine and your new machine is the same, that's not what OS X cares about under the covers, it's the UID that counts. Like Rudi suggested, see if you can make a change to a file like the .git/config without needing to sudo. If you can't (which I suspect is the case), then the solution is probably just to sudo chown everything to your new user.
Adrian Petrescu