Bo's blog

Saturday, March 03, 2012

setup apache for GIT


working apache config:

SetEnv GIT_PROJECT_ROOT D:/shares/repos/
SetEnv GIT_HTTP_EXPORT_ALL

ScriptAlias /git/ "C:/Program Files/Git/libexec/git-core/git-http-backend.exe/"

  Options +ExecCGI
  Allow From All



Scenario 1: Allow anonymous pushes

Sometimes you may want to allow users to push to your repositories without authentication, for example when using an internal, privately hosted server.
To enable this scenario, edit the config file in C:RepositoriesTest.git on the server and add the following lines to the bottom of the file:
[http]
  receivepack = true
This will allow git to accept pushes from anonymous users.
Note that you’ll have to add this to every repository that you create. I’ll show a nicer way to do this later in the tutorial.

Scenario 2: Anonymous pull, authenticated push

This is the default scenario. Git will only allow users to push if they have been authenticated with apache.
There are several ways to enable user accounts with apache. The most basic is to use .htaccess files, although you can also configure integration with Windows user accounts and Active Directory by using mod_authnz_ldap. Configuring these is outside the scope for this tutorial, but there are plenty of examples on the internets.
Once authentication is set up, you’ll need to ensure that you clone your repositories with the username in the URL, as git will not prompt you for a username by default:
git clone http://MyUserName@mygitserver/Test.git
Git will then prompt you for a password every time that you try to push. You can also hard code the password in the URL (somewhat insecure) if you want to avoid this prompt:
git clone http://MyUserName:Password@mygitserver/Test.git
To make this more secure, you could enable SSL on the server and require authenticated traffic to go over HTTPS. Although configuring OpenSSL with apache is outside the scope for this tutorial, I will point out that once configured, you will need to disable the SSL verification on your git client by running:
git config --global http.sslverify false
If you don’t do this, you’ll get an error saying “error setting certificate verify locations” every time you try to clone/push/pull over HTTPS.




Ref: Hosting a Git server under Apache on Windows
http://maymay.net/blog/2008/08/08/how-to-use-http-basic-authentication-with-git/

Labels: ,

0 Comments:

Post a Comment

<< Home