posted by jwerner on Thursday, March 7, 2013 5:20 PM

This how-to describes setting up a Git http-backend on a Windows server with XAMPP.


All code examples below starting with $ ... have to be executed in the Git Bash shell.

Setting up a repository on the server

On the XAMPP server, the webroot by default is in C:\xampp\htdocs.

Create a new directory for git repositories below the webroot:

$ cd /c/xampp/htdocs
$ mkdir git
$ cd git
$ git --bare init new-repo.git
$ ls

Setting up Apache for Git

Creating an Apache Password File

  • The following code creates the password file with the username paultester:
$ cd /c/xampp
$ apache/bin/htpasswd.exe -c security/git.htpasswd paultester
Automatically using MD5 format.
New password: *******
Re-type new password: *******
Adding password for user paultester

Adding Git Settings

XAMPP splits its Apache configuration settings into a main httpd.conf file and some extra files for special purposes.

  • Ensure mod_cgi, mod_alias, and mod_env are enabled (httpd.conf).
  • Create a new file C:\xampp\apache\conf\extra\httpd-git.conf:
<Directory "C:/Program Files/Git/libexec/git-core/">
    Options +ExecCGI
    Allow From All

SetEnv GIT_PROJECT_ROOT C:/xampp/htdocs/git
ScriptAlias /git/ "C:/Progra~1/Git/libexec/git-core/git-http-backend.exe/"

<LocationMatch "^/.*/git-receive-pack$">
    Options +ExecCGI
    AuthType Basic
    AuthName "Git"
    AuthUserFile "C:/xampp/security/git.htpasswd"
    Require valid-user

<LocationMatch "^/.*/git-upload-pack$">
    Options +ExecCGI
    AuthType Basic
    AuthName "Git"
    AuthUserFile "C:/xampp/security/git.htpasswd"
    Require valid-user
  • Edit the httpd.conf file and append including the new extra config file:
# File: C:\xampp\apache\conf\httpd.conf
# Git repositories
Include "conf/extra/httpd-git.conf"
  • Restart Apache

Creating a local repository

  • Switch to your development PC
  • Create an environment variable HOME which points to your home directory, e.g. C:\Users\paultester
$ cd /c/projects
$ git init new-repo
$ cd new-repo/
  • Add the remote in your local repository
  • Replace with the webserver's hostname:
$ git-config remote.upload.url \
  • Add some code to your repository:
$ echo "Some text..." > README
$ git add .
$ git commit -m "Initial commit"
  • Push the repo to the webserver:
$ git push upload master
Counting objects: 5, done.
Writing objects: 100% (3/3), 252 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To http://paultester@localhost/git/new-repo.git
   c33709a..6b2ac51  master -> master

Tips and Tricks

  • Continuously monitor the apache access and error log files:
$ tail -f /c/xampp/apache/logs/{access,error}.log &

To avoid to always enter the password, create a filer _netrc ├Čn your %HOME% directory:

machine <servername> login paultester password <paulspassword>
  • Replace <servername> with the webserver's hostname and <paulspassword> with your password.

If you use a proxy to access the internet, but don't require one to access the webserver holding the remote rpositories, add this to your local repo's `.git/config``file:

[remote "upload"]
    url = http://paultester@localhost/git/new-repo.git
    proxy =

Additional Reading


No comments

Please enter the letters as they are shown in the image above.
Letters are not case-sensitive.

Add comment

Change Log

Created OnMar 7, 2013 5:20:30 PM CET
Created ByJoachim Werner
Updated OnSep 23, 2013 10:42:35 AM CEST
Updated ByJoachim Werner (jwerner)