I recently needed to publish a Git repository to an Apache server for simple sharing with a collaborator. There are a few guides out there, but there’s a key missing step required with the current Git releases for the simple publish-over-SSH-clone-over-HTTP model.
On the server, run the following commands in the directory which you want to contain the repository after changing PROJECT to the actual name of the project:
mkdir PROJECT.git cd PROJECT.git git --bare init git update-server-info -f chmod +x hooks/post-update
The -f options for update-server-info appears to now be necessary the first time you update the repository (subsequent pushes seem fine without it). None of the guides I found with a quick search used it so I assume it changed at some point fairly recently.
You can now publish to this repository over SSH:
git push server:path/to/PROJECT.git master
At this point your collaborators can clone the repository:
git clone http://server/path/to/PROJECT.git
Note: if you do this often, add it as a remote so you can simply push to a convenient name (replacing PROJECT_HTTP_NAME with whatever’s memorable to you):
git remote add PROJECT_HTTP_NAME host:path/to/PROJECT.git