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

后端 未结 2 1691
小鲜肉
小鲜肉 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:51

    On the server I ran sudo chown -R git:git /srv/git/ - this fixed my problem but I am wondering if this was the correct thing to do?

    Absolutely. The problem previously was that the git user, who you're logging in as via SSH, could not write to the repository.

    Depending on your needs, you may consider different combinations of users and SSH keys, or one of the many additional programs (gitolite etc) that can be used to more finely control access.

提交回复
热议问题