I am aware that there are similar issues about git relating to the \'unable to unlink\' warning, but I have not been able to use them.
The main difference is that th
I had this error inside a virtual machine (running Ubuntu), when I tried to do git reset --hard
.
The fix was simply to run git reset --hard
from the OS X host machine instead.
In my case the permission problem solved by setting www-data
as an owner:
chown -R www-data project_folder_name
"Unlink" essentially means "delete file" in this case.
This error is not caused by git itself. You should have similar errors deleting those files manually, in a command line or file explorer.
I usually see that kind of error when there is a process not releasing the handle of those files.
Make sure nothing is running, and then try your checkout again.
Note: it can also be related with the way Git has been installed (on Windows, UAC can generate problem if msysgit is installed in C:\Program
or C:\Program Files
, see "msysgit - sh.exe - fork: Permission denied - Vista 64 bit" and comment 2 of issue 437)
Note: as illustrated below, a common other cause of the problem is rights issue on the directory (wrong owner), not necessarily on the file that can't be unlinked.
In my first encounter with this error my user had rights to "write" to the file but not the containing directory. Check the permissions of the directory containing the file.
None of the other suggestions worked for me, but this did:
sudo git reflog expire --expire=now --all && sudo git gc --prune=now --aggressive