Let's say you want to distribute some big files to the whole world.
You can of course, just drop them onto a website. But perhaps you'd like to
use git-annex to manage those files. And as an added bonus, why not let
anyone in the world clone your site and use git-annex get
!
My site like this is downloads.kitenet.net. Here's how I set it up. --Joey
- Set up a web site. I used Apache, and configured it to follow symlinks.
Options FollowSymLinks
- Put some files on the website. Make sure it works.
git init; git annex init
git config core.sharedrepository world
(Makes sure files are always added with permissions that allow everyone to read them.)- We want users to be able to clone the git repository over http, because
git-annex can download files from it over http as well. For this to
work,
git update-server-info
needs to get run after commits. The gitpost-update
hook will take care of this, you just need to enable the hook.chmod +x .git/hooks/post-update
git annex add; git commit -m added
- Make sure users can still download files from the site directly.
- Instruct advanced users to clone a http url that ends with the "/.git/"
directory. For example, for downloads.kitenet.net, the clone url
is
https://downloads.kitenet.net/.git/
- Set up a git
post-receive
hook to update the repository's working tree when changes are pushed to it. See below for details.
When users clone over http, and run git-annex, it will automatically learn all about your repository and be able to download files right out of it, also using http.
post-receive hook
If you have git-annex 4.20130703, the post-receive hook mentioned above
in step 9 just needs to run git annex merge
.
With older versions of git-annex, you can instead use git annex sync
.
There are two gotchas with some versions of git to be aware of when writing this post-receive hook.
- The hook may be run with the current directory set to the
.git
directory, and not the top of your work tree. So you need tocd ..
or similar in the hook. GIT_DIR
may be set to.
, which will not be right after changing directory. So you will probably want to unset it.
Here's a post-receive hook that takes these problems into account:
#!/bin/sh unset GIT_DIR cd .. git annex merge
The post is pretty clear but I misinterpreted at first and got stuck for a while, so just in case this helps anyone else:
The issues about the
post-receive
hook running in the.git
directory andGIT_DIR
being set to.
are distinct issues and you might need to fix both them. At first, I thought they were the same thing and just doingcd ..
would be enough to fix things, but it is not.For those not wanting to run their own web server, using Amazon S3 with git-annex can work well; it can be configured to let the public download files over http. See public Amazon S3 remote.
Is there a low cost web hosting solution that would support a public git-annex repo relatively simply with simple access to download the public files.
I figure I could set up an Amazon EC2 micro instance and mount an s3 share, hosting the git-annex remote, but this is a lot of overhead for something that dropbox does with 1 click "share dropbox link"?
Any suggestions would be great!
You can choose which files get stored in the public repository, and are thus accessible to the public. However, note that since the git repository is published, anyone could clone it and see all the names and hashes of your files, even if you've not pushed the file contents to the public repository.
Currently the way the "public" repository group works only makes it be usable with special remotes. This is because it uses a
preferreddir
setting in the special remote configuration.Hi,
would it be possible to do this whith the contents of a public repository-group (a non-bare public repository)?