4

I've got a git repository on my file server which I'm connecting to via AFP. Whenever I try to do a git operation on the shared repository, such as staging a file, I get the following error message:

fatal: Unable to write new index file

If I execute the git command on the server it works fine, so there's something about sharing the repository via AFP that's not working.

I'm using Mountain Lion on both the server and the client.

UPDATE

I seem to have write permission for both .git and .git/index:

$ ls -ld .git
drwxr-xr-x  1 david  staff  364 Nov 29 22:38 .git/
$ ls -l .git/index
-rw-r--r--  1 david  staff  2232 Nov 29 21:45 .git/index
$ cp .git/index backup
$ echo change >> .git/index

I tried recursively applying permissions to .git as suggested by an answer below, but that didn't help:

$ chmod -Rv +w .git
$ git add deploy.js 
fatal: Unable to write new index file

Hmm, it looks like someone else is using the index file:

$ cp .git/index backup; mv backup .git/index
mv: rename backup to .git/index: Resource busy

But fuser and lsof aren't of any help:

$ fuser -fu .git/index
.git/index: 
$ lsof .git/index

Weird workaround: If I do the following command on the server, it allows me to write a new index file on the client over AFP.

$ cp .git/index backup; mv backup .git/index

I'm totally lost at this point; any new theories?

1
  • I would suggest that git is usually (best?) saved on your local disk. Then you can clone to a server for backup - or have another repo running as a git server.
    – mmmmmm
    Commented Mar 9, 2018 at 11:26

4 Answers 4

2

We've run into the same issue repeatedly, especially as we try to use XCode 6. I'm currently changing over my connect to our server to WebDAV (connecting to our server via Finder > Go (menubar) > Connect to Server... > https://localnetworkIP/userfolder/).

This is working for us (so far).

UPDATE: After a few days, I noticed a new issue using WebDAV: files would disappear from view in the Finder causing XCode/Git to think that the file had been deleted. Looking at the server showed that the files were still there.

I then changed my connection type to SMB. This has worked well for me: Git no longer encounters file permission errors, and Finder (OSX 10.10 Yosemite) doesn't "loose" files.

0

The error indicates that it can't write to .git/index, which usually means that it can't write to .git either.

Make sure that you have permission to .git and recursively apply such permissions to the contents of the folder and subfolders, and new files that are created.

1
  • Good guess, but I seem to have permission. Please see the update to my question. Commented Nov 30, 2013 at 1:42
0

I get this intermittently, and typing git status on the remote host fixes it for me.

1
  • Thanks, I'm not using Git over AFP any more but I'll try your idea the next time I do. Commented Feb 19, 2015 at 4:20
0

Although this answer may not satisfy your needs, Mercurial works on AFP volume without any problem.

I've run into the same issue. Git is my primary VCS, however I did not have any better way rather than switching to Mercurial in that case.

Fortunately the switch was easy since both tools are very similar within the scope of basic usage.

You must log in to answer this question.

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