Git Checkout warning: unable to unlink files, permission denied

后端 未结 26 1098
梦毁少年i
梦毁少年i 2020-12-04 08:46

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

相关标签:
26条回答
  • 2020-12-04 09:11

    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.

    0 讨论(0)
  • 2020-12-04 09:11

    In my case the permission problem solved by setting www-data as an owner:

    chown -R www-data project_folder_name
    
    0 讨论(0)
  • 2020-12-04 09:13

    "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.

    0 讨论(0)
  • 2020-12-04 09:14

    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.

    0 讨论(0)
  • 2020-12-04 09:15

    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.

    0 讨论(0)
  • 2020-12-04 09:15

    None of the other suggestions worked for me, but this did:

    sudo git reflog expire --expire=now --all && sudo git gc --prune=now --aggressive

    0 讨论(0)
提交回复
热议问题