Creating a git Server

Really, there is no such thing.

Installing Git

For this to work nicely you have to have at least git-1.7

Git & Aapache

This configuration is to simply create a read-only central repository for your project. The repository is still "push-able", just over SSH.

Local Repo Steps

Our project is called "praxis" for this example, we are starting in our project directory. The web-root on the server is /var/www.

Here are the steps to initially publish your project to this HTTP git server.

. $ cd ..
. $ git clone --bare ./praxis.git ./bare-praxis.dir
. rsync -av bare-praxis.dir user@server:/var/www/git/praxis.git/

Server Repo Steps

Once on the server, it's a simple matter of updating the repo information.

. $ ssh user@server
~ $ cd /var/www/praxis.git
~ $ ls
HEAD  config  description  hooks  info  objects  packed-refs  refs
. $ git --bare update-server-info

NB: for the ssh-push to work properly you must enable the post-update hook for git.

. $ mv ./hooks/post-update.sample ./hooks/post-update
. $ chmod 0750 ./hooks/post-update
. $ cat ./hooks/post-update
exec git update-server-info

Cloning and Pushing

Now you can pull from this central public repo, and push back via SSH.

~ $ git clone http://server/git/praxis.git ./local-praxis.dir/

Branch, stash, checkout and hack to your hearts content.

~ $ git push ssh://server/var/www/git/praxis.git master

See Also

Loading Comments from Disqus...