tags:

views:

258

answers:

3

I have an Ubuntu server and have installed git and gitosis. I am new to server administration and have the following gitosis folder tree: /home/git/repositories

I have edited the user's rights to different repositories by cloning gitosis-admin.git to my local machine, edited gitosis.conf and added user's public keys to the keydir and pushed it back to the server. This has been tested with various repositories and works.

I am really confused by the tutorials that describe how gitosis can be used to create a repository that can be used to source-control a folder in the web domain.

I have created a bare repository in the web folder using SSH Putty; added and committed the files to it. Then cloned it to local machine with

git clone git(at)server:web_repo.git

This was successful.

The problem is that when I try to push it back to the server, a repo is created in the /home/git/repositories path and the web folder repo is not affected.

I have tried combining the info from:

http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way

http://urbanpuddle.com/articles/2008/07/11/installing-git-on-a-server-ubuntu-or-debian

http://danielmiessler.com/blog/using-git-to-maintain-your-website

http://toroid.org/ams/git-website-howto

http://www.ibm.com/developerworks/web/library/wa-git/

A: 

Did you set up a post-update hook in the /home/git/repositories-repo, as described in the "Enabling Auto-Updates Upon Pushing Changes From Your Dev Box"-section on http://danielmiessler.com/blog/using-git-to-maintain-your-website ? This should be the trick to get the content from the central repo to the live-clone. For this to work, the git-user needs write access to the live-clone.

kusma
Thank you for your response.Yes, did modify the /home/git/repositories/hooks/post-update file to:#!/bin/sh#WORKDIR="/var/www/folder/folder/folder/html_folder/"export GIT_DIR="$WORKDIR/.git"pushd $WORKDIR > /dev/nullgit pullpopd > /dev/nullNot sure if exec git-update-server-info is relevant?Then 755'd it.I don't know how to set the git-user to have write permissions on the /var/www/folder/folder/folder/html_folder though....
Tubby
OK, have now run chown -R on the git repo folder and it still doesn't work.
Tubby
I think what pfote is saying is that you should remove the '#' before the WORKDIR assignment, as it is commented out.
kusma
indeed, that was my point
pfote
A: 

from what you posted in your comments, your shell script is broken, WORKDIR is not set (that line is a remark)

however, i don't think it's a good idea what you have in mind (with one exception: what you try to update is your development server)

pfote
Good point - but I thought that was the whole idea of git and gitosis - restricted source control. Sure, we test our code before going live, I just want to automate the process from git repo to live server... It looks like capistrano would be one solution, but I am on a win pc and wanted to avoid installing even more software when it is (apparently) possible to update the site with the update hooks.
Tubby
now that you mention capistrano is think i know what you lookin for: simple way to deploy your stuff. git doesn't care about deployment, neither does gitosis, wrong scope. please refine/extend your question, doesn't make much sense to discuss that in the comments
pfote
+1  A: 

It might be helpful to know what version of ubuntu you're using. Gitosis is probably in the apt-get repository, and it's in Debian Lenny for sure. Installing from the repository is much more clean in my experience. Given the potential for security problems in this software, I'd strongly recommend using the repo. But it's up to you. If the pulling and pushing succeed there's no harm in this approach.

When you push to a git repository with gitosis, the hooks (the post-update is the one you need here.) are executed as the gitosis or git user. I suspect your problem is related to this. You might consider writing a suid post-update hook, so that it can execute as your user account or as the web-editor or web-server user. You could alternately chown -R git:git (or gitosis:gitosis depending on your setup) the local deployment clones. If you have to edit these repositories on the server, remember to use sudo -u git to make whatever changes as the proper user.

tychoish