git-annex/ special remotes/ git

Normally a git repository is not treated as a special remote, but as a git remote of the normal kind. Two exceptions to that are git-lfs and gcrypt special remotes.

But it is possible to register a git repository as a special remote. git-annex and git will use the remote the same as any normal git remote, but its url will be recorded in the repository. One benefit of doing this is it allows git-annex init to autoenable the remote.

To set up such a special remote:

    git annex initremote myremote type=git location=ssh://... autoenable=true

Now `git annex init` in each clone of the repository will autoenable myremote.

This only works for git repositories that have a git-annex uuid set, because special remotes have to have a uuid. So it cannot be used with git repositories that are not git-annex repositories.

Simple config amendment for Apache served repositories

If you follow the git-http-backend documentation for serving repositories via Apache, you'll read this section:

``

To serve gitweb at the same url, use a ScriptAliasMatch to only those URLs that git http-backend can handle, and forward the rest to gitweb:

    ScriptAliasMatch \
        "(?x)^/git/(.*/(HEAD | \
                info/refs | \
                objects/(info/[^/]+ | \
                     [0-9a-f]{2}/[0-9a-f]{38} | \
                     pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
                git-(upload|receive)-pack))$" \
        /usr/libexec/git-core/git-http-backend/$1

    ScriptAlias /git/ /var/www/cgi-bin/gitweb.cgi/

If you add the following AliasMatch between the two ScriptAlias directives, you can get Apache to serve the (...).git/config file to the http client, in this case git-annex.

    AliasMatch "(?x)^/git/(.*/config)$" /var/www/git/$1

This allows the annexes to use the autoenable=true to pin the centralisation afforded by the git only repository. Keep a "source of truth" so to speak (acknowledging that this is antithetical to what git-annex aims to do).

As an aside, the tip to generate a uuid didn't seem to work for me. But I suspect I missed the point somewhat.

Regardless, if you are able to alter the configuration of your "centralised" git repository, this might be of assistance.

Comment by beryllium — Tue Jul 22 18:11:47 2025
comment 2

This can only be used for git remotes that have an annex-uuid set. All special remotes have to have a uuid. git remotes that are hosted on a system with git-annex installed get the annex-uuid set up automatically, but it won't happen if your special remote is on github or something like that. You could `git config remote.foo.annex-uuid $(uuid)` to generate and set a new uuid, I suppose.

Comment by joey — Tue Jul 22 18:11:47 2025
type=git special remote cannot be enabled, no uuid is generated
Following the instructions here, I cannot enable the remote. The error message is: `git-annex: Unknown remote name.`. I assume this is because git annex does not create a uuid for the type=git special remote, presumably because non is set for the actual git remote (the annex-uuid key does not exist for the existing git remote with the same url). This is the relevant line generated in remote.log: `autoenable=true location=<ssh-url> name=<name> type=git timestamp=1629118438.628919s`, as you can see there is no uuid at the beginning. Any ideas if this is a bug or if the instructions are outdated?
Comment by matthias.risze — Tue Jul 22 18:11:47 2025
Comments on this page are closed.