Error while pull from git - insufficient permission for adding an object to repository database .git/objects

前端 未结 5 675
臣服心动
臣服心动 2021-01-29 21:12

I have git error: \"insufficient permission for adding an object to repository database .git/objects\" every time I make \"git pull origin develop\".

    remote:         


        
相关标签:
5条回答
  • 2021-01-29 21:56

    Assuming @ChrisHayes is right about an accidental sudo, this should fix it. From inside your repository:

    sudo chown -R $USER:$USER "$(git rev-parse --show-toplevel)/.git"
    

    Update: for those of you getting the illegal group name error, try this instead:

    sudo chown -R $(id -u):$(id -g) "$(git rev-parse --show-toplevel)/.git"
    
    0 讨论(0)
  • 2021-01-29 22:04

    remove .git from the url, if you are trying to clone a public repository from github.

    example:

    From: https://github.com/example/repository.git To: https://github.com/example/repository

    0 讨论(0)
  • 2021-01-29 22:04

    NOT A GOOD PRACTICE (Just an alternative)

    I am using Ubuntu and faced the same problem. To solve it, I simply switched user to root and I see no further error.

    $su
    password
    

    Then,

    $git pull origin master
    

    Recommended way: CHANGE THE PERMISSION OF THE DIRECTORY

    0 讨论(0)
  • 2021-01-29 22:07

    Go to project's root directory and run below commands to fix this issue,

    cd .git/objects
    sudo chown -R yourname:yourgroup *
    
    0 讨论(0)
  • 2021-01-29 22:07

    Mine was a stupid mistake... the right username and group were set, but www-data was the account accessing it. The directory was owned by vaindil:www-data, but permissions were 755 so www-data couldn't write to it. Fixed it with:

    $ sudo chmod -R 775 /path/to/repo
    
    0 讨论(0)
提交回复
热议问题