So I usually create git hook like this (root only):
git init --bare
nano /home/git-repo/www.example.com.git/hooks//post-receive
Paste this
#!/bin/sh
GIT_WORK_TREE=/home/nginx/domains/www.example.com/public git checkout -f
GIT_WORK_TREE=/home/nginx/domains/www.example.com/public git checkout -f master
GIT_WORK_TREE=/home/nginx/domains/www.example.com/public git clean -f
Then
chmod +x /home/git-repo/www.example.com.git/hooks//post-receive
But now I tried create new user for access git repository and set permission so new user only can access some git repository and what I tried is:
useradd NewUser
groupadd Developer
usermod -G Developer NewUser
chgrp Developer /home/git-repo/www.example.com.git/hooks//post-receive
chmod +x /home/git-repo/www.example.com.git/hooks//post-receive
But when I push I am getting this error:
Counting objects: 1549, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (826/826), done.
fatal: Unable to create temporary file: Permission denied
fatal: sha1 file '<stdout>' write error: Broken pipe
error: failed to push some refs to 'ssh://NewUser@(my.vps.ip.0):(port)/home/git-repo/www.example.com.git'
How to solve my problem? I just need to create git repo with hooks and new user can only access some of my git repository