# Did you run git update-server-info on the server?

If you try to setup git-http-backend for Apache and see the message:

fatal: http://example.com/prefix/path/to/repository.git/info/refs not found:
did you run git update-server-info on the server?

and you think you did everything you could, but nothing helps, change

SetEnv GIT_HTTP_EXPORT_ALL

to

SetEnv GIT_HTTP_EXPORT_ALL 1

Why?

Usually this error message means that Apache config paths are wrong or Git URL used to clone is not correct (it is always printed by Git client if the server sends “404 Not found” response). For these settings:

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


and Git repository in

C:\Repositories\path\to\repository.git

Git URL will be

http://example.com/prefix/path/to/repository.git

If you use another URL, you’ll see this error message.

But this is not enough. To be able to work with the repositories you should export them, otherwise from git-http-backend’s point of view these repositories do not exist, and it sends 404 as response and prints this line to error.log

[...] Repository not exported: 'C:/Repositories/path/to/repository.git'


There’re 2 ways to “export” the repository.

1. Create an empty file named
C:/Repositories/path/to/repository.git/git-daemon-export-ok
2. Set environment variable of git-http-backend GIT_HTTP_EXPORT_ALL using SetEnv directive. Although official Git documentation recommends to use this line
SetEnv GIT_HTTP_EXPORT_ALL

some Apache versions (at least 2.2, at least on Windows) have a bug: if the value is not specified, the environment variable is not set. As a workaround you can set it to arbitrary value, git-http-backend only checks whether the variable is set or not:

SetEnv GIT_HTTP_EXPORT_ALL 1

# VisualSVN Subversion Server and Git

I’d like to start this blog with a few real-world examples on how to set up SubGit assuming infrastructure that is already in place. This post will take place in a strange world of Windows.

Initial configuration: VisualSVN Server on 64-bit Windows computer, provides read and write access to two Subversion repositories over HTTPS.

Primary Objective: Make Subversion repositories accessible for reading and modification with Git over HTTPS.
Secondary Objective: Reuse existing authentication settings, that are already configured for Subversion repositories.

In other words I’m about to set up instant bidirectional Svn to Git replication.

### Configuration Details

This is a VisualSVN configuration I’ve created for this guide:

As you may see project repository is a single-project one with a standard trunk/branches/tags layout, and main repository contains two subproject, each with a standard layout.

VisualSVN is installed in C:\Program Files (x86)\VisualSVN Server directory.
Repositories are located in C:\Repositories directory.
VisualSVN uses standard Subversion authentication settings.

### Add Git to Svn

First, install msysGit, you may download installer from their download page. Make sure you select this option when installing msysGit (it is important for enabling HTTP access later!):

Second, change an account VisualSVN service uses and modify C:\Repository directory (one where repositories are kept) permissions as described in a Visual SVN knowledge base entry. It is important to make VisualSVN service run on behalf of the account that has access to the Git you’ve just installed. Following the way of lesser resistance, I’ve used my personal account for that, but you may create a dedicated one.

After completing this step, I had VisualSVN service running on behalf of “HOST\alex” account and C:\Repository was writable for “HOST\alex”. Yes, my name is Alex.

Finally, download SubGit zip archive and unpack it into C:\SubGit directory. The run “subgit install” on Subversion repositories to enable replication:

> C:\SubGit\bin\subgit install C:\Repositories\main
> C:\SubGit\bin\subgit install C:\Repositories\project


Install SubGit

Note, that you must run “subgit install” on behalf of the same user that you’ve configured VisualSVN service with.

### Configure HTTP Access for Git

Important: VisualSVN comes with more or less truncated version of Apache, but fortunately it misses only one module of those needed for Git (mod_cgi). Download it (mod_cgi.so from Apache 2.2.21 for win32) and put into C:\Program Files (x86)\VisualSVN Server\bin directory.

Alternatively, you may get this missing module by installing Apache and taking mod_cgi.so file from the modules folder.

Then, edit C:\Program Files (x86)\VisualSVN Server\conf\httpd-custom.conf file:

LoadModule cgi_module bin/mod_cgi.so

SetEnvIf Request_URI "^/git/.*$" GIT_PROJECT_ROOT=C:/Repositories SetEnvIf Request_URI "^/git/.*$" GIT_HTTP_EXPORT_ALL

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

<Location /git>
Options +ExecCGI

Require valid-user
AuthName "VisualSVN Server"
AuthType Basic
AuthBasicProvider file
AuthUserFile "C:/Repositories/htpasswd"
</Location>


Note, that this configuration example uses “Basic” authentication option, granting read and write access to repositories for all Git users that are listed in htpasswd file. Of course you may configure something more complicated here.

Now restart VisualSVN Server service. That’s all!

### Git for Svn

Try the following commands now:

# set this environment variable in case you're using SSL and
# self-signed SSL certificate in VisualSVN (this is default).
> SET GIT_SSL_NO_VERIFY=true

> git clone https://alex@localhost/git/project project
> git clone https://alex@localhost/git/main/git/library lib


Thanks to SubGit, changes pushed from the cloned Git repository will be immediately propagated to the corresponding Svn repository and vice versa – new Svn revisions will be received by a pull performed from a cloned Git repository.

You may find more on SubGit at http://subgit.com/