Git push error: Unable to unlink old (Permission denied)

前端 未结 14 1157
庸人自扰
庸人自扰 2020-11-29 16:32

In the remote server I have a post-receive hook set up in order to make a git checkout of my repository:

#!/bin/sh
GIT_WORK_TREE=/var/www/ git         


        
相关标签:
14条回答
  • 2020-11-29 16:51

    If you are using any IDE most likely the problem is that file was used by some process. Like your tomcat might be using the file. Try to identify that particular process and close it. That should solve your problem.

    0 讨论(0)
  • 2020-11-29 16:51

    This is an old question, but this may help Mac users.

    If you are copying files from Time Machine manually, instead of restoring them through Time Machine, it'll add ACLs to everything, which can mess up your permissions.

    For example, the section in this article that says "How to Fix Mac OS X File Permissions" shows that "everyone" has custom permissions, which messes it all up:

    You need to remove the ACLs from those directories/files. This Super User answer goes into it, but here's the command:

    sudo chmod -RN .

    Then you can make sure your directories and files have the proper permissions. I use 750 for directories and 644 for files.

    0 讨论(0)
  • 2020-11-29 16:51

    I get this error, and other strange git errors, when I have a server running (in Intellij). Stopping the server and re-trying the git command frequently fixes it for me.

    0 讨论(0)
  • 2020-11-29 16:52

    Some files are write-protected that even git cannot over write it. Change the folder permission to allow writing e.g. sudo chmod 775 foldername

    And then execute

    git pull 
    

    again

    0 讨论(0)
  • 2020-11-29 16:54

    I think the problem may be with the ownership to the folder so set it to the current user ownership

    sudo chown -R your_login_name /path/to/folder
    
    You can find the solution [here][1]
    0 讨论(0)
  • 2020-11-29 16:58

    I had the same issue and none of the solutions above worked for me. I deleted the offending folder. Then:

    git reset --hard
    

    Deleted any lingering files to clean up the git status, then did:

    git pull
    

    It finally worked.

    NOTE: If the folder was, for instance, a public folder with build files, remember to rebuild the files

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