Xcode: Git repository error while adding files

Problem

I have encountered Xcode 4.4.1 error while adding files (cannot add) to the project:

fatal: Unable to create ‚/Volumes/{Project Path}/.git/index.lock’: File exists.

But, I cannot find this file under Finder or Terminal. Also deleting repository doesn’t give any positive results.

Solution

Open Terminal and write following command. Replace example path with yours, copied from Xcode requester (don’t forget about apostophe/quotation marks in path if contains spaces):

sudo rm -f '/Volumes/Data/My Devs/Apple/Project Folder/.git/index.lock'

That’s all

Discussion

Give your feedback