Following the instructions in A web-focused Git workflow I set up a prime and hub repository on my web server and then cloned the hub to my machine at home.
I started testing commits and pushes with changed files in documentroot and the changes would appear fine on the root of the webserver. However, when I tried to push a file in a subdirectory, I rec'd the following message:
remote:
remote: **** Pulling changes into Prime [Hub's post-update hook]
remote:
remote: From /home/git/site_hub
remote: * branch master -> FETCH_HEAD
remote: error: unable to create file academy/testthegit2.html (Permission denied)
Again, no permission issues in the web root, but put a file in a subdir and an error is tossed.
The git user is in the apache group and the sub-directories are chmod 755.
Here is the hub's post-update:
#!/bin/sh
echo
echo "**** Pulling changes into Prime [Hub's post-update hook]"
echo
cd /usr/local/apache/htdocs || exit
unset GIT_DIR
git pull hub master
exec git-update-server-info
and the prime (document root's) post-update:
#!/bin/sh
echo
echo "**** pushing changes to Hub [Prime's post-commit hook]"
echo
git push hub
To reiterate, works in root, fails in subdir.
Thanks for any advice.
You need to add a wrapper to correct permissions on your post-update hook. Depending on how is your server setup, involves different steps. I'll describe my use case and hopefully you can adapt it to your needs.
In my server, the bare repositories (hub ones) are managed by gitosis/gitolite/plain git user with git-shell. Files under
$GITOSIS_HOME
are owned bygitosis:gitosis
and are umasked077
.For the changes to be pulled correctly, I needed to add a call to a helper script I'm storing in
/usr/local/bin
that recursively sets owner, group, permissions and SELinux context in the prime/live repository.Incidentally, I also needed to add a line to my
sudoers(5)
file to allowgitosis
to run the script as root with!requiretty
andNOPASSWD
.