fatal: Unable to create temporary file '/home/username/git/myrepo.git/./objects/pack/tmp_pack_XXXXXX': Permission denied

前端 未结 8 987
独厮守ぢ
独厮守ぢ 2020-12-23 09:00

I have been having trouble with this error message and I don\'t understand the proper solution to fix it or go about debugging it. I have googled the error in various forms

相关标签:
8条回答
  • 2020-12-23 09:52

    I resolved it by giving permission to the user on each of the directories that you're using, like so:

    sudo chown user /home/user/git
    

    and so on.

    0 讨论(0)
  • 2020-12-23 09:55

    Ok, I figured it out. The issue was that I didn't have the correct permissions set for myrepo.git and the parent directory git.

    As root I logged into the server and used:

    $ chown username /home/username/git
    

    This then returns drwxrwxr-x 4 username root 4096 2012-10-30 15:51 /home/username/git with the following:

    $ ls -ld /home/username/git
    

    I then make a new directory for myrepo.git inside git:

    $ mkdir myrepo.git
    $ ls -ld myrepo.git/
    drwxr-xr-x 2 root root 4096 2012-10-30 18:41 myrepo.git/
    

    but it has the user set to root, so I change it to username the same way as before.

    $ chown username myrepo.git/
    $ ls -ld myrepo.git/
    drwxr-xr-x 2 username root 4096 2012-10-30 18:41 myrepo.git/
    

    I then sign out of root and sign into server as username:

    Inside git directory:

    $ cd myrepo.git/
    $ git --bare init
    Initialized empty Git repository in /home/username/git/myrepo.git/
    

    On local machine:

    $ git remote add origin      
    ssh://username@server.com/home/username/git/myrepo.git
    $ git push origin master
    

    SUCCESS!

    Hopefully this comes in handy for anyone else that runs into the same issue in the future!

    Resources

    • http://www.cyberciti.biz/tips/unix-or-linux-commands-for-changing-user-rights.html
    • http://www.cyberciti.biz/faq/how-to-use-chmod-and-chown-command/
    0 讨论(0)
提交回复
热议问题