How to fix permission denied for .git/ directory when performing git push?

后端 未结 2 1645
小鲜肉
小鲜肉 2021-02-01 22:25

I have set up a git repository on my server. Created a new user \'git\'. My repos are located in /srv/git/example.git. I was able to git remote add origin git

2条回答
  •  长发绾君心
    2021-02-01 22:39

    First, fix file permissions in your remote .git dir e.g.

    sudo chmod -R ug+w /var/www/.git
    sudo chown -R git:git /var/www/.git
    

    or root:root if you want to assign members of root group for push access.

    Then git repository on the destination host needs to be set as shared, so the following command on remote needs to be run:

    git config core.sharedRepository group
    

提交回复
热议问题