I have a lot of git repositories on my linux (ubuntu) server. I access all of them with the Apache user www-data. This worked great in the past because I was the only web developer. Now I have more developers and I need to restrict their access to some repositories. How do I modify my server/permissions/git repositories to accomodate this?
Let me show you the current process I go through to set up a repository.
To set up a new repository for the project project on myserver.com, I issue the following commands from terminal:
ssh www-data@myserver.com
password: (password for www-data)
cd /var/lib/repositories/
mkdir project.git
cd project.git
git init --bare
git update-server-info
cd /var/www/git.myserver.com/
ln -s /var/lib/repositories/project.git project
To deploy the project to the url http://project.myserver.com, I issue the following commands from terminal:
ssh project@myserver.com
password: (password for project)
cd /var/www/project.myserver.com/public_html/
git init
git remote add origin http://www-data@git.myserver.com/project
git pull origin master
password: (password for www-data)
The user project needs to know the password for www-data to push and pull from the git repository.
How do I modify my server/permissions/gitrepositories so that I can push and pull as project instead of www-data?
Additional Notes
Here's what the vhost entry for git.myserver.com looks like
<VirtualHost 173.255.230.136:80>
ServerAdmin support@myserver.com
ServerName git.myserver.com
DocumentRoot /var/www/git.myserver.com/public_html/
ErrorLog /var/www/git.myserver.com/logs/error.log
CustomLog /var/www/git.myserver.com/logs/access.log combined
</VirtualHost>
The directory /var/lib/git is owned by the www-data user. This way, apache can write to the repos via the symbolic link in /var/www/git.myserver.com/public_html/project via the url http://www-data@git.evermight.com/project
git.myserver.comhost? And why are you logging on aswww-data? – Shane Madden Jan 7 at 6:14